Skip to content

Commit

Permalink
Add test that characterizes the current behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 31, 2024
1 parent c23fadf commit cff3c4a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/unit/Framework/MockObject/TestDoubleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use PHPUnit\TestFixture\MockObject\InterfaceWithNeverReturningMethod;
use PHPUnit\TestFixture\MockObject\InterfaceWithReturnTypeDeclaration;
use stdClass;
use TypeError;

abstract class TestDoubleTestCase extends TestCase
{
Expand Down Expand Up @@ -188,6 +189,20 @@ final public function testMethodCanBeConfiguredToReturnDifferentValuesOnConsecut
$this->assertTrue($double->doSomething());
}

final public function testMethodConfiguredToReturnDifferentValuesOnConsecutiveCallsCannotBeCalledMoreOftenThanReturnValuesHaveBeenConfigured(): void
{
$double = $this->createTestDouble(InterfaceWithReturnTypeDeclaration::class);

$double->method('doSomething')->willReturn(false, true);

$this->assertFalse($double->doSomething());
$this->assertTrue($double->doSomething());

$this->expectException(TypeError::class);

$double->doSomething();
}

final public function testMethodCanBeConfiguredToReturnDifferentValuesAndThrowExceptionsOnConsecutiveCalls(): void
{
$double = $this->createTestDouble(InterfaceWithReturnTypeDeclaration::class);
Expand Down

0 comments on commit cff3c4a

Please sign in to comment.