Skip to content

Commit fa0e4f6

Browse files
Add tests
1 parent f8129a6 commit fa0e4f6

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/unit/Framework/MockObject/ReturnValueGeneratorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use PHPUnit\TestFixture\MockObject\AnInterfaceForIssue5593;
2323
use PHPUnit\TestFixture\MockObject\AnotherInterface;
2424
use PHPUnit\TestFixture\MockObject\AnotherInterfaceForIssue5593;
25+
use PHPUnit\TestFixture\MockObject\ExtendableClass;
2526
use PHPUnit\TestFixture\MockObject\YetAnotherInterface;
2627
use stdClass;
2728

@@ -201,6 +202,22 @@ public function test_Generates_test_stub_for_first_intersection_of_interfaces_fo
201202
$this->assertInstanceOf(AnotherInterface::class, $value);
202203
}
203204

205+
public function test_Does_not_handle_union_of_extendable_class_and_interface(): void
206+
{
207+
$this->expectException(RuntimeException::class);
208+
$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');
209+
210+
$this->generate(ExtendableClass::class . '|' . AnInterface::class);
211+
}
212+
213+
public function test_Does_not_handle_intersection_of_extendable_class_and_interface(): void
214+
{
215+
$this->expectException(RuntimeException::class);
216+
$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');
217+
218+
$this->generate(ExtendableClass::class . '&' . AnInterface::class);
219+
}
220+
204221
public function test_Generates_test_stub_for_unknown_type(): void
205222
{
206223
$this->assertInstanceOf(Stub::class, $this->generate('ThisDoesNotExist'));

0 commit comments

Comments
 (0)