Skip to content

Commit

Permalink
Added regression test for sebastianbergmann#3602
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelHartmann committed Apr 30, 2019
1 parent f427c03 commit 5ba91cb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/Framework/MockObject/Builder/InvocationMockerTest.php
Expand Up @@ -176,4 +176,18 @@ public function testWillReturnValidTypeForLowercaseMethod(): void

$this->assertEquals(true, $mock->methodWithBoolReturnTypeDeclaration());
}

/**
* @see https://github.com/sebastianbergmann/phpunit/issues/3602
*/
public function testWillReturnFailsWhenTryingToReturnValueFromVoidMethod() : void
{
/** @var ClassWithAllPossibleReturnTypes|\PHPUnit\Framework\MockObject\MockObject $out */
$out = $this->createMock(ClassWithAllPossibleReturnTypes::class);
$method = $out->method('methodWithVoidReturnTypeDeclaration');

$this->expectException(IncompatibleReturnValueException::class);
$this->expectExceptionMessage('Method methodWithVoidReturnTypeDeclaration may not return value of type boolean');
$method->willReturn(true);
}
}

0 comments on commit 5ba91cb

Please sign in to comment.