Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Aug 14, 2023
1 parent 419b4c7 commit 9a98ae5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/unit/Framework/MockObject/TestDoubleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,24 @@ final public function testMethodCanBeConfiguredToReturnDifferentValuesOnConsecut
$this->assertTrue($double->doSomething());
}

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

$double->method('doSomething')->willReturnOnConsecutiveCalls(
false,
true,
$this->throwException(new Exception),
);

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

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

$double->doSomething();
}

final public function testMethodCanBeConfiguredToThrowAnException(): void
{
$expectedException = new Exception('exception configured using throwException()');
Expand Down

0 comments on commit 9a98ae5

Please sign in to comment.