|
24 | 24 | use Symfony\Component\DependencyInjection\ServiceLocator;
|
25 | 25 | use Symfony\Component\DependencyInjection\TypedReference;
|
26 | 26 | use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
|
| 27 | +use Symfony\Component\HttpKernel\Tests\Fixtures\Suit; |
27 | 28 |
|
28 | 29 | class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
29 | 30 | {
|
@@ -400,6 +401,25 @@ public function testAlias()
|
400 | 401 | $this->assertEqualsCanonicalizing([RegisterTestController::class.'::fooAction', 'foo::fooAction'], array_keys($locator));
|
401 | 402 | }
|
402 | 403 |
|
| 404 | + /** |
| 405 | + * @requires PHP 8.1 |
| 406 | + */ |
| 407 | + public function testEnumArgumentIsIgnored() |
| 408 | + { |
| 409 | + $container = new ContainerBuilder(); |
| 410 | + $resolver = $container->register('argument_resolver.service')->addArgument([]); |
| 411 | + |
| 412 | + $container->register('foo', NonNullableEnumArgumentWithDefaultController::class) |
| 413 | + ->addTag('controller.service_arguments') |
| 414 | + ; |
| 415 | + |
| 416 | + $pass = new RegisterControllerArgumentLocatorsPass(); |
| 417 | + $pass->process($container); |
| 418 | + |
| 419 | + $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); |
| 420 | + $this->assertEmpty(array_keys($locator), 'enum typed argument is ignored'); |
| 421 | + } |
| 422 | + |
403 | 423 | public function testBindWithTarget()
|
404 | 424 | {
|
405 | 425 | $container = new ContainerBuilder();
|
@@ -479,6 +499,13 @@ public function fooAction(string $someArg)
|
479 | 499 | }
|
480 | 500 | }
|
481 | 501 |
|
| 502 | +class NonNullableEnumArgumentWithDefaultController |
| 503 | +{ |
| 504 | + public function fooAction(Suit $suit = Suit::Spades) |
| 505 | + { |
| 506 | + } |
| 507 | +} |
| 508 | + |
482 | 509 | class WithTarget
|
483 | 510 | {
|
484 | 511 | public function fooAction(
|
|
0 commit comments