PHPackages                             biozshock/phpunit-consecutive - 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. biozshock/phpunit-consecutive

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

biozshock/phpunit-consecutive
=============================

Utility class to replace phpunit withConsecutive

1.0.4(1y ago)0868MITPHPPHP ^8.1CI passing

Since Mar 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/biozshock/phpunit-consecutive)[ Packagist](https://packagist.org/packages/biozshock/phpunit-consecutive)[ RSS](/packages/biozshock-phpunit-consecutive/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelogDependencies (6)Versions (10)Used By (0)

Repository provides utility class: "replacement" for removed `withConsecutive` from PHPUnit.
============================================================================================

[](#repository-provides-utility-class-replacement-for-removed-withconsecutive-from-phpunit)

Why?
----

[](#why)

[In the issue of PHPUnit](https://github.com/sebastianbergmann/phpunit/issues/4026) there are several possibilities to replace missing functionality `withConsecutive` of PHPUnit. Most of the comments use some sort of the callback:

```
$expectedArguments = [
    ...
]
->withConsecutive(function ($arg1, $arg2) use (&$index) {
    if ($index === 0) {
        self::assertEquals('some', $arg1);
        ...
    }
});
```

Eventually i've got sick of writing such code. Writing boilerplate and repeating yourself is no fun.

The class solve also the issue, where you need to operate with arguments &lt;-&gt; return value relation. Giving the developer an ability to define what's returned with each argument set.

Install
-------

[](#install)

```
composer require --dev biozshock/phpunit-consecutive
```

Usage
-----

[](#usage)

When you need to mock the method which returns a value.

```
$mock->method('add')
    ->withConsecutive($a, $b)
    ->willReturn(1, 2);
```

Is replaced by

```
$mock->method('add')
    ->willRecturnCallback(Consecutive::consecutiveMap([
        [$a, 1],
        [$b, 2]
    ]));
```

Or return callback, which accepts given arguments:

```
$mock->method('add')
    ->willRecturnCallback(Consecutive::consecutiveMap([
        [$a, $b, static function (int $a, string $b): bool {
            return $a === (int) $b;
        }],
        [$c, $d, static function (int $c, string $d): bool {
            return str_starts_with($d, (string) $c);
        }]
    ]));
```

Also, you can test methods that return one of arguments. In this example the test expects zero-index argument `$a` to be returned:

```
$mock->method('add')
    ->willRecturnCallback(Consecutive::consecutiveMap([
        [$a, $b],
        [$a, $d]
    ], 0));
```

Otherwise, when mocked method returns `void`.

```
$mock->method('add')
    ->withConsecutive($a, $b);
```

Is replaced by

```
$mock->method('add')
    ->willRecturnCallback(Consecutive::consecutiveCall([
        [$a],
        [$b]
    ]));
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance45

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~3 days

Total

6

Last Release

424d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/543497fcc4f3b4a35601dd49735731319a5cb6fa9ff3d0b9694f4d07de231325?d=identicon)[biozshock](/maintainers/biozshock)

---

Top Contributors

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

---

Tags

phpunitdevconsecutive

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/biozshock-phpunit-consecutive/health.svg)

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

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpstan/phpstan

PHPStan - PHP Static Analysis Tool

13.9k341.8M29.6k](/packages/phpstan-phpstan)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[phpmd/phpmd

PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.

2.4k108.5M4.8k](/packages/phpmd-phpmd)[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

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