Created
March 25, 2021 10:11
-
-
Save lstrojny/78582e82eb6ba950241a89922fe4e6ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Test; | |
use PHPUnit\Framework\TestCase; | |
interface SystemUnderTest { | |
public function first(int $arg): int; | |
public function second(string $arg): string; | |
} | |
final class CallOrderTest extends TestCase | |
{ | |
private $sut; | |
protected function setUp(): void | |
{ | |
parent::setUp(); | |
$this->sut = $this->createMock(SystemUnderTest::class); | |
$this->sut | |
->expects(self::once()) | |
->method('first') | |
->id('first') | |
->with(1) | |
->willReturn(2); | |
$this->sut | |
->expects(self::once()) | |
->after('first') | |
->method('second') | |
->with('foo') | |
->willReturn('bar'); | |
} | |
public function testCorrectOrder(): void | |
{ | |
self::assertSame(2, $this->sut->first(1)); | |
self::assertSame('bar', $this->sut->second('foo')); | |
} | |
public function testWrongOrder(): void | |
{ | |
self::assertSame('bar', $this->sut->second('foo')); | |
self::assertSame(2, $this->sut->first(1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment