<?php
use PHPUnit\Framework\TestCase;
class Consecutive2Test extends TestCase
{
public function testIsBar() : void
{
$foo = $this->createFooMock();
$this->assertTrue($foo->isBar(true, true));
$this->assertTrue($foo->isBar(false, true));
$this->assertTrue($foo->isBar(true, false));
}
public function testIsBarWrongOrder() : void
{
$foo = $this->createFooMock();
$this->assertTrue($foo->isBar(false, true));
$this->assertTrue($foo->isBar(true, false));
$this->assertTrue($foo->isBar(true, true));
}
private function createFooMock()
{
$foo = $this->createMock(Foo::class);
$foo->expects($this->exactly(3))
->method('isBar')
->withConsecutive(
[true, true],
[false, true],
[true, false]
)
->willReturn(true);
return $foo;
}
}
class Foo
{
public function isBar($value1, $value2)
{
return $value1 || $value2;
}
}
Result
Time: 00:00.018, Memory: 18.00 MB
There was 1 failure:
1) Consecutive2Test::testIsBarWrongOrder
Expectation failed for method name is "isBar" when invoked 3 time(s)
Parameter 0 for invocation #0 Foo::isBar(false, true) does not match expected value.
Failed asserting that false matches expected true.
Consecutive2Test.php:20
FAILURES!
Tests: 2, Assertions: 0, Failures: 1.