PHPackages                             m00t/phpspec-phpunit-matchers - 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. m00t/phpspec-phpunit-matchers

ActiveLibrary

m00t/phpspec-phpunit-matchers
=============================

Changes IdentityMatcher from '===' to PHPUnit's assertEquals()

26121[1 PRs](https://github.com/m00t/phpspec-phpunit-matchers/pulls)PHP

Since Jan 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/m00t/phpspec-phpunit-matchers)[ Packagist](https://packagist.org/packages/m00t/phpspec-phpunit-matchers)[ RSS](/packages/m00t-phpspec-phpunit-matchers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PhpSpec PHPUnit Matchers
========================

[](#phpspec-phpunit-matchers)

This extension changes PhpSpec's IdentityMatcher from "===" to PHPUnit's assertEquals() method. Also it changes PhpSpec's differ to PHPUnit's one.

Motivation
----------

[](#motivation)

1\. PHPUnit has time proven comparation library than does more than just "==" or "===", so that we can simply use it and do not worry about using "shouldBeLike()" instead of "shouldReturn()".

2. Differ.

For example we have classes:

```
class Value
{
    private $value;

    public function __construct($value)
    {
        $this->value = $value;
    }
}

class TestValueObject
{
    public function getValue($value)
    {
        return new Value($value + 1);
    }
}

class TestValueObjectSpec extends ObjectBehavior
{
    function it_can_get_value()
    {
        $this->getValue(42)->shouldReturn(new \Value(42));
    }
}
```

PhpSpec output without this extension ("shouldReturn" was changed to "shouldBeLike")

```
$ bin/phpspec run spec/TestValueObjectSpec.php -v
TestValueObject
  10  ✘ it can get value
      expected [obj:Value], but got [obj:Value].

        10     function it_can_get_value()
        11     {
        12         $this->getValue(42)->shouldBeLike(new \Value(42));
        13     }
        14 }
        15

       0 vendor/phpspec/phpspec/src/PhpSpec/Matcher/ComparisonMatcher.php:74
         throw new PhpSpec\Exception\Example\NotEqualException("Expected [obj:Valu"...)
       1 [internal]
         spec\TestValueObjectSpec->it_can_get_value()

                       100%                        1
1 specs
1 example (1 failed)
30ms
```

PhpSpec output with this extension

```
$ bin/phpspec run spec/TestValueObjectSpec.php -v
TestValueObject
  10  ✘ it can get value
      expected [obj:Value], but got [obj:Value].

      --- Expected
      +++ Actual
      @@ @@
       Value Object (
      -    'value' => 42
      +    'value' => 43
       )

        10     function it_can_get_value()
        11     {
        12         $this->getValue(42)->shouldReturn(new \Value(42));
        13     }
        14 }
        15

       0 vendor/phpspec/phpspec/src/PhpSpec/Matcher/IdentityMatcher.php:83
         throw new PhpSpec\Exception\Example\NotEqualException("Expected [obj:Valu"...)
       1 [internal]
         spec\TestValueObjectSpec->it_can_get_value()

                       100%                        1
1 specs
1 example (1 failed)
48ms
```

Installation
------------

[](#installation)

1. Define dependencies in your `composer.json`:

```
{
    "require-dev": {
        ...

        "m00t/phpspec-phpunit-matchers": "dev-master",
    }
}
```

2. Install/update your vendors:

```
$ composer update m00t/phpspec-phpunit-matchers
```

3. Activate extension by specifying its class in your `phpspec.yml`:

```
# phpspec.yml
extensions:
    - M00t\PhpSpec\PHPUnitMatchers\Extension\PHPUnitMatchersExtension
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4bdaaa1cb674c4098acb9e3188d23bb66ccde097583bedcd5036924ee53c4db?d=identicon)[m00t](/maintainers/m00t)

---

Top Contributors

[![anton-siardziuk](https://avatars.githubusercontent.com/u/301661?v=4)](https://github.com/anton-siardziuk "anton-siardziuk (3 commits)")

### Embed Badge

![Health badge](/badges/m00t-phpspec-phpunit-matchers/health.svg)

```
[![Health](https://phpackages.com/badges/m00t-phpspec-phpunit-matchers/health.svg)](https://phpackages.com/packages/m00t-phpspec-phpunit-matchers)
```

PHPackages © 2026

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