PHPackages                             inspirum/phpunit-extension - 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. inspirum/phpunit-extension

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

inspirum/phpunit-extension
==========================

PHPUnit extension with additional assertions

v1.1.0(1y ago)14241MITPHPPHP ^8.1

Since May 17Pushed 1y agoCompare

[ Source](https://github.com/inspirum/phpunit-extension)[ Packagist](https://packagist.org/packages/inspirum/phpunit-extension)[ Docs](https://github.com/inspirum/phpunit-extension)[ RSS](/packages/inspirum-phpunit-extension/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (1)

PHPUnit extension
=================

[](#phpunit-extension)

[![Latest Stable Version](https://camo.githubusercontent.com/0d237fa9ef5820d7a104d5b4b6bb0a1375876357961ae0b980dbd53ac0f27957/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e73706972756d2f706870756e69742d657874656e73696f6e2e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d626c7565)](https://packagist.org/packages/inspirum/phpunit-extension)[![Build Status](https://camo.githubusercontent.com/bd5ef38cb1a23b1c968eee77fdd81aaab54a2a753a77195ae9e5ebdedf56b5d4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696e73706972756d2f706870756e69742d657874656e73696f6e2f6d61737465722e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/inspirum/phpunit-extension/actions)[![Coverage Status](https://camo.githubusercontent.com/e9ffcc9c2fd7635a20dfd58f2bf317aff6cafa0c68abcd9101506a7218ae1d74/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f696e73706972756d2f706870756e69742d657874656e73696f6e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/inspirum/phpunit-extension/code-structure)[![Quality Score](https://camo.githubusercontent.com/0aadbfe6ea67f96139d107739e736d9adfda40b00b7e16b6c1bab7da0574fb8f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f696e73706972756d2f706870756e69742d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/inspirum/phpunit-extension)[![PHPStan](https://camo.githubusercontent.com/4b1330d67416a001f59bf39d60499aec28a71f8ee2d3185777cae563373ef201/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c25323031302d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6162656c3d7068707374616e)](https://github.com/phpstan/phpstan)[![Total Downloads](https://camo.githubusercontent.com/58b476f6afc93ed421fd71d0cbb3a519b8bfc5f84afbd38469652282de06a4bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e73706972756d2f706870756e69742d657874656e73696f6e2e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d626c7565)](https://packagist.org/packages/inspirum/phpunit-extension/stats)[![Software License](https://camo.githubusercontent.com/1741f31b46e83540323421895d41f1dc1b163d8c64df124faa83bf3c95f96c80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f696e73706972756d2f706870756e69742d657874656e73696f6e2e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d626c7565)](./LICENSE.md)

PHPUnit extension with additional assertions and other helpers.

- Support some deprecated functionality
- Easy to implement

Features
--------

[](#features)

Supports deprecated assertion method `withConsecutive`

Before PHPUnit 10.0

```
use PHPUnit\Framework\TestCase;

final class CalculatorTest extends TestCase
{
    public function testMultiply(): void
    {
        $mock = $this->createMock(Calculator::class);

        $arguments = [[1,2,3], [4,5,6]]
        $responses = [6, 120]

        $mock->expects($this->exactly(count($arguments)))->method('multiply')
            ->withConsecutive(...$arguments)
            ->willReturnOnConsecutiveCalls(...$responses);

        // ... test
    }
}
```

After PHPUnit 10.0

```
use Inspirum\PHPUnit\Extension;
use PHPUnit\Framework\TestCase;

final class CalculatorTest extends TestCase
{
    use Extension;

    public function testMultiply(): void
    {
        $mock = $this->createMock(Calculator::class);

        $arguments = [[1,2,3], [4,5,6]]
        $responses = [6, 120]

        $mock->expects($this->exactly(count($arguments)))->method('multiply')
            ->will(self::withConsecutive($arguments, $responses));

        // ... test
    }
}
```

System requirements
-------------------

[](#system-requirements)

- [PHP 8.1+](http://php.net/releases/8_1_0.php)

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

[](#installation)

Run composer require command

```
$ composer require inspirum/phpunit-extension
```

or add requirement to your `composer.json`

```
"inspirum/phpunit-extension": "^1.0"
```

Usage
-----

[](#usage)

Validate arguments and responses:

```
$mock->expects($this->exactly(2))->method('example')
    ->will(self::withConsecutive(
        arguments: [
            [1, 2, 0.1],
            [2, 3, 0.01],
        ],
        responses: [
            true,
            false,
        ],
    ));

self::assertTrue($mock->example(1, 2, 0.1));
self::assertFalse($mock->example(2, 3, 0.01));
```

Optional responses:

```
$mock->expects($this->exactly(2))->method('example')
    ->will(self::withConsecutive(
        arguments: [
            [1, 2, 0.1],
            [2, 3, 0.01],
        ],
    ));

$mock->example(1, 2, 0.1);
$mock->example(2, 3, 0.01);
```

Simplification for same response for each call

```
$mock->expects($this->exactly(2))->method('example')
    ->will(self::withConsecutive(
        arguments: [
            [1, 2, 0.1],
            [2, 3, 0.01],
        ],
        responses: true,
    ));

self::assertTrue($mock->example(1, 2, 0.1));
self::assertTrue($mock->example(2, 3, 0.01));
```

Supports throwing exceptions:

```
$mock->expects($this->exactly(2))->method('example')
    ->will(self::withConsecutive(
        arguments: [
            [1, 2, 0.1],
            [2, 3, 0.01],
        ],
        responses: [
           true,
           new RuntimeException('Custom error'),
        ],
    ));

self::assertTrue($mock->example(1, 2, 0.1));

try {
    $mock->example(2, 3, 0.01);
} catch (RuntimeException $exception) {
    self::assertSame('Custom error', $exception->getMessage());
}
```

Testing
-------

[](#testing)

To run unit tests, run:

```
$ composer test:test
```

To show coverage, run:

```
$ composer test:coverage
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](./docs/CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](./docs/CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Tomáš Novotný](https://github.com/tomas-novotny)
- [All Contributors](https://github.com/inspirum/phpunit-extension/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](./LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

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

Every ~187 days

Total

2

Last Release

581d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e2804b72261a28767b27deae892144e2a2c6a09a0d71d149631606346731d52d?d=identicon)[tomas-novotny](/maintainers/tomas-novotny)

---

Top Contributors

[![tomas-novotny](https://avatars.githubusercontent.com/u/36948723?v=4)](https://github.com/tomas-novotny "tomas-novotny (8 commits)")

---

Tags

phpunitphpunit-assertionswith-consecutivetestingphpunitassertionsextensionwith-consecutive

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/inspirum-phpunit-extension/health.svg)

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

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k129.9M910](/packages/brianium-paratest)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69519.1M606](/packages/spatie-phpunit-snapshot-assertions)[nette/tester

Nette Tester: enjoyable unit testing in PHP with code coverage reporter. 🍏🍏🍎🍏

4857.5M1.6k](/packages/nette-tester)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1489.3M94](/packages/ergebnis-phpunit-slow-test-detector)[facile-it/paraunit

paraunit

145802.1k15](/packages/facile-it-paraunit)[shopsys/http-smoke-testing

HTTP smoke test case for testing all configured routes in your Symfony project

67266.6k2](/packages/shopsys-http-smoke-testing)

PHPackages © 2026

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