Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 31, 2024
1 parent f8129a6 commit fa0e4f6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/unit/Framework/MockObject/ReturnValueGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use PHPUnit\TestFixture\MockObject\AnInterfaceForIssue5593;
use PHPUnit\TestFixture\MockObject\AnotherInterface;
use PHPUnit\TestFixture\MockObject\AnotherInterfaceForIssue5593;
use PHPUnit\TestFixture\MockObject\ExtendableClass;
use PHPUnit\TestFixture\MockObject\YetAnotherInterface;
use stdClass;

Expand Down Expand Up @@ -201,6 +202,22 @@ public function test_Generates_test_stub_for_first_intersection_of_interfaces_fo
$this->assertInstanceOf(AnotherInterface::class, $value);
}

public function test_Does_not_handle_union_of_extendable_class_and_interface(): void
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Return value for OriginalClassName::methodName() cannot be generated because the declared return type is a union, please configure a return value for this method');

$this->generate(ExtendableClass::class . '|' . AnInterface::class);
}

public function test_Does_not_handle_intersection_of_extendable_class_and_interface(): void
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Return value for OriginalClassName::methodName() cannot be generated because the declared return type is an intersection, please configure a return value for this method');

$this->generate(ExtendableClass::class . '&' . AnInterface::class);
}

public function test_Generates_test_stub_for_unknown_type(): void
{
$this->assertInstanceOf(Stub::class, $this->generate('ThisDoesNotExist'));
Expand Down

0 comments on commit fa0e4f6

Please sign in to comment.