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.4.0(1mo ago)05.0k↓61.4%10MITHackCI passing

Since May 18Pushed 1mo 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 3d ago

READMEChangelog (7)Dependencies (4)Versions (8)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

41

—

FairBetter than 87% of packages

Maintenance89

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity32

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 ~59 days

Recently: every ~77 days

Total

7

Last Release

55d 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 (43 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

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M360](/packages/dms-phpunit-arraysubset-asserts)[quizlet/hammock

Hammock is a stand-alone mocking library for Hacklang.

27445.5k](/packages/quizlet-hammock)[hackpack/hackunit

An xUnit testing framework for Hack

612.7k14](/packages/hackpack-hackunit)

PHPackages © 2026

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