|
7 | 7 | use DI\Container; |
8 | 8 | use PHPUnit\Framework\TestCase; |
9 | 9 | use StaticPHP\DI\CallbackInvoker; |
| 10 | +use StaticPHP\Exception\SPCInternalException; |
10 | 11 |
|
11 | 12 | /** |
12 | 13 | * Helper class that requires constructor parameters for testing |
13 | 14 | */ |
14 | | -class UnresolvableTestClass |
| 15 | +readonly class UnresolvableTestClass |
15 | 16 | { |
16 | | - public function __construct( |
17 | | - private string $requiredParam |
18 | | - ) {} |
| 17 | + /** @noinspection PhpPropertyOnlyWrittenInspection */ |
| 18 | + public function __construct(private string $requiredParam) {} |
19 | 19 | } |
20 | 20 |
|
21 | 21 | /** |
@@ -92,7 +92,7 @@ public function testInvokeCallbackWithContainerResolution(): void |
92 | 92 |
|
93 | 93 | // Should not resolve from container as 'test.service' is not a type |
94 | 94 | // Will try default value or null |
95 | | - $this->expectException(\RuntimeException::class); |
| 95 | + $this->expectException(SPCInternalException::class); |
96 | 96 | $this->invoker->invoke($callback); |
97 | 97 | } |
98 | 98 |
|
@@ -139,7 +139,7 @@ public function testInvokeCallbackThrowsExceptionForUnresolvableParameter(): voi |
139 | 139 | return $required; |
140 | 140 | }; |
141 | 141 |
|
142 | | - $this->expectException(\RuntimeException::class); |
| 142 | + $this->expectException(SPCInternalException::class); |
143 | 143 | $this->expectExceptionMessage("Cannot resolve parameter 'required' of type 'string'"); |
144 | 144 | $this->invoker->invoke($callback); |
145 | 145 | } |
@@ -527,7 +527,7 @@ public function testInvokeWithUnionTypeThrowsException(): void |
527 | 527 | $callback = eval('return function (string|int $param) { return $param; };'); |
528 | 528 |
|
529 | 529 | // Union types are not ReflectionNamedType, should not be resolved from container |
530 | | - $this->expectException(\RuntimeException::class); |
| 530 | + $this->expectException(SPCInternalException::class); |
531 | 531 | $this->invoker->invoke($callback); |
532 | 532 | } |
533 | 533 |
|
@@ -594,7 +594,7 @@ public function testInvokeWithContainerExceptionAndNoFallback(): void |
594 | 594 | return $obj; |
595 | 595 | }; |
596 | 596 |
|
597 | | - $this->expectException(\RuntimeException::class); |
| 597 | + $this->expectException(SPCInternalException::class); |
598 | 598 | $this->expectExceptionMessage("Cannot resolve parameter 'obj'"); |
599 | 599 |
|
600 | 600 | $this->invoker->invoke($callback); |
|
0 commit comments