|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;
|
| 16 | +use Symfony\Component\DependencyInjection\ChildDefinition; |
16 | 17 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 | 18 | use Symfony\Component\DependencyInjection\Reference;
|
18 | 19 |
|
@@ -69,12 +70,19 @@ public function testDefaultFailureHandler($serviceId, $defaultHandlerInjection)
|
69 | 70 | $this->assertEquals(new Reference('security.authentication.failure_handler.foo.abstract_factory'), $arguments['index_6']);
|
70 | 71 | $failureHandler = $container->findDefinition((string) $arguments['index_6']);
|
71 | 72 |
|
| 73 | + $expectedFailureHandlerOptions = ['login_path' => '/bar']; |
72 | 74 | $methodCalls = $failureHandler->getMethodCalls();
|
73 | 75 | if ($defaultHandlerInjection) {
|
74 | 76 | $this->assertEquals('setOptions', $methodCalls[0][0]);
|
75 |
| - $this->assertEquals(['login_path' => '/bar'], $methodCalls[0][1][0]); |
| 77 | + $this->assertEquals($expectedFailureHandlerOptions, $methodCalls[0][1][0]); |
76 | 78 | } else {
|
77 | 79 | $this->assertCount(0, $methodCalls);
|
| 80 | + $this->assertInstanceOf(ChildDefinition::class, $failureHandler); |
| 81 | + $this->assertEquals('security.authentication.custom_failure_handler', $failureHandler->getParent()); |
| 82 | + $failureHandlerArguments = $failureHandler->getArguments(); |
| 83 | + $this->assertInstanceOf(ChildDefinition::class, $failureHandlerArguments['index_0']); |
| 84 | + $this->assertEquals($serviceId, $failureHandlerArguments['index_0']->getParent()); |
| 85 | + $this->assertEquals($expectedFailureHandlerOptions, $failureHandlerArguments['index_1']); |
78 | 86 | }
|
79 | 87 | }
|
80 | 88 |
|
@@ -108,13 +116,22 @@ public function testDefaultSuccessHandler($serviceId, $defaultHandlerInjection)
|
108 | 116 | $successHandler = $container->findDefinition((string) $arguments['index_5']);
|
109 | 117 | $methodCalls = $successHandler->getMethodCalls();
|
110 | 118 |
|
| 119 | + $expectedSuccessHandlerOptions = ['default_target_path' => '/bar']; |
| 120 | + $expectedFirewallName = 'foo'; |
111 | 121 | if ($defaultHandlerInjection) {
|
112 | 122 | $this->assertEquals('setOptions', $methodCalls[0][0]);
|
113 |
| - $this->assertEquals(['default_target_path' => '/bar'], $methodCalls[0][1][0]); |
| 123 | + $this->assertEquals($expectedSuccessHandlerOptions, $methodCalls[0][1][0]); |
114 | 124 | $this->assertEquals('setFirewallName', $methodCalls[1][0]);
|
115 |
| - $this->assertEquals(['foo'], $methodCalls[1][1]); |
| 125 | + $this->assertEquals($expectedFirewallName, $methodCalls[1][1][0]); |
116 | 126 | } else {
|
117 | 127 | $this->assertCount(0, $methodCalls);
|
| 128 | + $this->assertInstanceOf(ChildDefinition::class, $successHandler); |
| 129 | + $this->assertEquals('security.authentication.custom_success_handler', $successHandler->getParent()); |
| 130 | + $successHandlerArguments = $successHandler->getArguments(); |
| 131 | + $this->assertInstanceOf(ChildDefinition::class, $successHandlerArguments['index_0']); |
| 132 | + $this->assertEquals($serviceId, $successHandlerArguments['index_0']->getParent()); |
| 133 | + $this->assertEquals($expectedSuccessHandlerOptions, $successHandlerArguments['index_1']); |
| 134 | + $this->assertEquals($expectedFirewallName, $successHandlerArguments['index_2']); |
118 | 135 | }
|
119 | 136 | }
|
120 | 137 |
|
|
0 commit comments