Skip to content

Commit 26a0e99

Browse files
author
Michael Petri
committed
fixed support for is-anything arguments
1 parent 77c2d48 commit 26a0e99

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/ConsecutiveArguments.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace MichaelPetri\PhpunitConsecutiveArguments;
66

77
use PHPUnit\Framework\Constraint\Callback;
8+
use PHPUnit\Framework\Constraint\IsAnything;
89

910
final class ConsecutiveArguments
1011
{
@@ -34,7 +35,7 @@ public static function of(array $firstConsecutiveArgument, array ...$additionalC
3435
$arguments = \array_pad(
3536
$arguments,
3637
$argumentCount,
37-
null
38+
new IsAnything()
3839
);
3940

4041
/** @var mixed $argument */
@@ -55,7 +56,8 @@ static function (mixed $actualArgument) use (&$argumentsGroupedByPosition, $argu
5556
? \array_shift($argumentsGroupedByPosition[$argumentPosition])
5657
: null;
5758

58-
return $expectedArgument === $actualArgument;
59+
return $expectedArgument === $actualArgument
60+
|| $expectedArgument instanceof IsAnything;
5961
}
6062
);
6163
}

tests/ConsecutiveArgumentsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ public function testWithAnythingCallback(): void
154154
->method('variadic')
155155
->with(
156156
...ConsecutiveArguments::of(
157-
[new IsAnything(), '1.2', '1.3'],
158-
['2.1', new IsAnything(), '2.3'],
159-
['3.1', '3.2', new IsAnything()],
160-
)
157+
[new IsAnything(), '1.2', '1.3'],
158+
['2.1', new IsAnything(), '2.3'],
159+
['3.1', '3.2', new IsAnything()],
160+
)
161161
);
162162

163163
$this->mock->variadic('1.1', '1.2', '1.3');

0 commit comments

Comments
 (0)