|
22 | 22 | use PHPUnit\TestFixture\MockObject\AnInterfaceForIssue5593; |
23 | 23 | use PHPUnit\TestFixture\MockObject\AnotherInterface; |
24 | 24 | use PHPUnit\TestFixture\MockObject\AnotherInterfaceForIssue5593; |
| 25 | +use PHPUnit\TestFixture\MockObject\ExtendableClass; |
25 | 26 | use PHPUnit\TestFixture\MockObject\YetAnotherInterface; |
26 | 27 | use stdClass; |
27 | 28 |
|
@@ -119,17 +120,35 @@ public function test_Generates_callable_for_Closure(): void |
119 | 120 |
|
120 | 121 | public function test_Generates_Generator_for_Generator(): void |
121 | 122 | { |
122 | | - $this->assertInstanceOf(Generator::class, $this->generate('Generator')); |
| 123 | + $value = $this->generate('Generator'); |
| 124 | + |
| 125 | + $this->assertInstanceOf(Generator::class, $value); |
| 126 | + |
| 127 | + foreach ($value as $element) { |
| 128 | + $this->assertSame([], $element); |
| 129 | + } |
123 | 130 | } |
124 | 131 |
|
125 | 132 | public function test_Generates_Generator_for_Traversable(): void |
126 | 133 | { |
127 | | - $this->assertInstanceOf(Generator::class, $this->generate('Traversable')); |
| 134 | + $value = $this->generate('Traversable'); |
| 135 | + |
| 136 | + $this->assertInstanceOf(Generator::class, $value); |
| 137 | + |
| 138 | + foreach ($value as $element) { |
| 139 | + $this->assertSame([], $element); |
| 140 | + } |
128 | 141 | } |
129 | 142 |
|
130 | 143 | public function test_Generates_Generator_for_iterable(): void |
131 | 144 | { |
132 | | - $this->assertInstanceOf(Generator::class, $this->generate('iterable')); |
| 145 | + $value = $this->generate('iterable'); |
| 146 | + |
| 147 | + $this->assertInstanceOf(Generator::class, $value); |
| 148 | + |
| 149 | + foreach ($value as $element) { |
| 150 | + $this->assertSame([], $element); |
| 151 | + } |
133 | 152 | } |
134 | 153 |
|
135 | 154 | public function test_Generates_test_stub_for_class_or_interface_name(): void |
@@ -201,6 +220,22 @@ public function test_Generates_test_stub_for_first_intersection_of_interfaces_fo |
201 | 220 | $this->assertInstanceOf(AnotherInterface::class, $value); |
202 | 221 | } |
203 | 222 |
|
| 223 | + public function test_Does_not_handle_union_of_extendable_class_and_interface(): void |
| 224 | + { |
| 225 | + $this->expectException(RuntimeException::class); |
| 226 | + $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'); |
| 227 | + |
| 228 | + $this->generate(ExtendableClass::class . '|' . AnInterface::class); |
| 229 | + } |
| 230 | + |
| 231 | + public function test_Does_not_handle_intersection_of_extendable_class_and_interface(): void |
| 232 | + { |
| 233 | + $this->expectException(RuntimeException::class); |
| 234 | + $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'); |
| 235 | + |
| 236 | + $this->generate(ExtendableClass::class . '&' . AnInterface::class); |
| 237 | + } |
| 238 | + |
204 | 239 | public function test_Generates_test_stub_for_unknown_type(): void |
205 | 240 | { |
206 | 241 | $this->assertInstanceOf(Stub::class, $this->generate('ThisDoesNotExist')); |
|
0 commit comments