PHPackages                             fasano/phpunit-oop - 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. fasano/phpunit-oop

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

fasano/phpunit-oop
==================

Object-oriented test case design for PHPUnit

v1.0.0(7mo ago)08MITPHP

Since Dec 5Pushed 7mo agoCompare

[ Source](https://github.com/n-fasano/phpunit-oop)[ Packagist](https://packagist.org/packages/fasano/phpunit-oop)[ RSS](/packages/fasano-phpunit-oop/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHPUnit OOP
===========

[](#phpunit-oop)

**Object-oriented test case design for PHPUnit.**

This library doesn't add features. It adds **constraints that encourage clarity**.

The goal: bring the same design principles to your tests that you bring to your production code: encapsulation, polymorphism, and meaningful names. [Read more](docs/RATIONALE.md)

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

[](#installation)

```
composer require --dev fasano/phpunit-oop
```

Core Concepts
-------------

[](#core-concepts)

### TestSuite

[](#testsuite)

Your test classes now extend `TestSuite` (which extends PHPUnit's `TestCase`):

```
use Fasano\PhpUnitOop\TestSuite;

class SomeFeatureTest extends TestSuite
{
    public static function cases(): array
    {
        return [
            'Case name' => new MyCaseObject(...),
            'Another case' => new AnotherCaseObject(...),
        ];
    }
}
```

### TestCase

[](#testcase)

Individual test scenarios extend `TestCase`:

```
use Fasano\PhpUnitOop\TestCase;

class SuccessCase extends TestCase
{
    public function __construct(
        public readonly MyClass $object,
        public readonly MyInput $input,
        public readonly MyResult $result,
    ) {}

    public function verify(): void
    {
        Assert::equals($this->result, $this->object->process($this->input));
    }
}
```

The `verify()` method contains your assertions. It is automatically called by the test runner.

### Assert

[](#assert)

A thin wrapper around PHPUnit's assertions to avoid naming collisions and unify the API:

```
use Fasano\PhpUnitOop\Assert;

Assert::true($condition);
Assert::false($condition);
Assert::equals($expected, $actual);
Assert::throws($exception, fn() => $this->dangerousOperation());
```

Requirements
------------

[](#requirements)

- PHP 8.4 (other versions untested)
- PHPUnit 12.4 (other versions untested)

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance65

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

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

Unknown

Total

1

Last Release

210d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/16bb6f7b889777bcd3237bbddd90a3707306fc1803da0bd10c3710086b8702a4?d=identicon)[nfasano](/maintainers/nfasano)

---

Top Contributors

[![n-fasano](https://avatars.githubusercontent.com/u/46872160?v=4)](https://github.com/n-fasano "n-fasano (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fasano-phpunit-oop/health.svg)

```
[![Health](https://phpackages.com/badges/fasano-phpunit-oop/health.svg)](https://phpackages.com/packages/fasano-phpunit-oop)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

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

14429.2M361](/packages/dms-phpunit-arraysubset-asserts)[gong023/assert_chain

enable you to use phpunit assert with method chain

1478.9k3](/packages/gong023-assert-chain)

PHPackages © 2026

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