PHPackages                             hershel-theodore-layton/expect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. hershel-theodore-layton/expect

ActiveLibrary[Testing &amp; Quality](/categories/testing)

hershel-theodore-layton/expect
==============================

Basic test assertions `expect(...)-&gt;toEqual('valid')`.

v0.3.0(2mo ago)04.1k↑26.7%10MITHackCI passing

Since May 18Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/hershel-theodore-layton/expect)[ Packagist](https://packagist.org/packages/hershel-theodore-layton/expect)[ RSS](/packages/hershel-theodore-layton-expect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (10)

Expect
======

[](#expect)

*Basic test assertions `expect(...)->toEqual('valid')`.*

This package replaces and is inspired by [fbexpect](https://github.com/hhvm/fbexpect).

Usage
-----

[](#usage)

You pass the expression under test to `expect(...)` as the first argument. The returned object exposes some common assertions you'd want to make about a value, such as `->toEqual()`. The simplest test you could write is:

```
expect(1 + 1)->toEqual(2);
```

Customization
-------------

[](#customization)

If your assertion is not included in the basic set, fear not. You can create your own assertions object. Simply use the `BasicAssertions` trait in a class and add methods specific to your project to it. For example:

```
use namespace HH\Lib\Str;
use namespace HTL\Expect;

final class MyAssertions {
  use Expect\BasicAssertions;

  public function __construct(private T $value)[] {}

  protected function getValue()[]: T {
    return $this->value;
  }

  public function toThrowMyDomainExpection(
  )[]: void where {
    try {
      ($this->value)();
      throw new Expect\Surprise(
        'Expected a MyDomainException to be thrown, but no exception was thrown.'
      );
    } catch (\Exception $e) {
      if (!$e is T) {
        throw new Expect\Surprise(Str\format(
          'Expected a MyDomainException to be thrown, but got %s instead.',
          \get_class($e),
        ));
      }
    }
  }
}
```

Then create your own `expect()` function in your own namespace:

```
function expect(T $value)[]: MyAssertions {
  return new MyAssertions($value);
}
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance84

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~55 days

Recently: every ~68 days

Total

6

Last Release

86d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d16d159b7061287c506d4ab44d05ae042bc4ec697116d1bd132a007634d9ff21?d=identicon)[Hershel Theodore Layton](/maintainers/Hershel%20Theodore%20Layton)

---

Top Contributors

[![hershel-theodore-layton](https://avatars.githubusercontent.com/u/81193606?v=4)](https://github.com/hershel-theodore-layton "hershel-theodore-layton (39 commits)")

### Embed Badge

![Health badge](/badges/hershel-theodore-layton-expect/health.svg)

```
[![Health](https://phpackages.com/badges/hershel-theodore-layton-expect/health.svg)](https://phpackages.com/packages/hershel-theodore-layton-expect)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78768.9M1.5k](/packages/phpstan-phpstan-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
