PHP code example of biozshock / phpunit-consecutive

1. Go to this page and download the library: Download biozshock/phpunit-consecutive library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

biozshock / phpunit-consecutive example snippets


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

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

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

$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);
        }]
    ]));

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

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

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