PHPackages                             hshn/phpunit-object-constraint - 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. hshn/phpunit-object-constraint

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

hshn/phpunit-object-constraint
==============================

v0.1.0(8y ago)210MITPHPPHP ^7.0.0

Since Jan 17Pushed 8y ago1 watchersCompare

[ Source](https://github.com/hshn/phpunit-object-constraint)[ Packagist](https://packagist.org/packages/hshn/phpunit-object-constraint)[ RSS](/packages/hshn-phpunit-object-constraint/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

phpunit-object-constraint [![Build Status](https://camo.githubusercontent.com/deb23f9eede06b86b1319290f65d5a3ca131a9d9ad64a054ca5c432591960a2d/68747470733a2f2f7472617669732d63692e6f72672f6873686e2f706870756e69742d6f626a6563742d636f6e73747261696e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hshn/phpunit-object-constraint)
===================================================================================================================================================================================================================================================================================================================================================

[](#phpunit-object-constraint-)

PHPUnit helper for explicit object comparison.

Make it easier to your apps more safety by providing easy object assertion.

How to use
----------

[](#how-to-use)

### 1. Import helper trait into your class

[](#1-import-helper-trait-into-your-class)

```
use Hshn\PHPUnit\Framework\Constraint\ObjectConstraintSupport;

class MyTest extends \PHPUnit_Framework_TestCase
{
    use ObjectConstraintSupport;
}
```

### 2. Build your object constraint using constraint builder

[](#2-build-your-object-constraint-using-constraint-builder)

```
public function test1()
{
    // this constraint means:
    //      property 'foo' start with 'a' and end with 'e'
    //  and property 'bar' is true
    $constraint = $this->constraintFor(\stdClass::class)
        ->property('foo')
            ->stringStartsWith('a')
            ->stringEndsWith('e')
        ->property('bar')
            ->isTrue()
        ->getConstraint();
}
```

### 3. Assert any value with the constraint you built

[](#3-assert-any-value-with-the-constraint-you-built)

```
self::assertThat($value, $constraint);
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3085d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1334026?v=4)[Shota Hoshino](/maintainers/hshn)[@hshn](https://github.com/hshn)

---

Top Contributors

[![hshn](https://avatars.githubusercontent.com/u/1334026?v=4)](https://github.com/hshn "hshn (14 commits)")

### Embed Badge

![Health badge](/badges/hshn-phpunit-object-constraint/health.svg)

```
[![Health](https://phpackages.com/badges/hshn-phpunit-object-constraint/health.svg)](https://phpackages.com/packages/hshn-phpunit-object-constraint)
```

###  Alternatives

[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69619.1M606](/packages/spatie-phpunit-snapshot-assertions)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.0M321](/packages/drupal-core-dev)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

30300.1k6](/packages/webmozarts-strict-phpunit)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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