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 2d 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 27% 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

3039d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ac9ad9cf40d96cebaf45553d5b286f611e847e4ca17a67d5f057ae2b1968def?d=identicon)[hshn](/maintainers/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

69417.9M510](/packages/spatie-phpunit-snapshot-assertions)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

76460.0k15](/packages/robiningelbrecht-phpunit-pretty-print)

PHPackages © 2026

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