|
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 |
|
18 | 19 | class AbstractFactoryTest extends TestCase
|
@@ -43,12 +44,19 @@ public function testDefaultFailureHandler($serviceId, $defaultHandlerInjection)
|
43 | 44 |
|
44 | 45 | $failureHandler = $this->container->getDefinition('security.authentication.failure_handler.foo.stub');
|
45 | 46 |
|
| 47 | + $expectedFailureHandlerOptions = ['login_path' => '/bar']; |
46 | 48 | $methodCalls = $failureHandler->getMethodCalls();
|
47 | 49 | if ($defaultHandlerInjection) {
|
48 | 50 | $this->assertEquals('setOptions', $methodCalls[0][0]);
|
49 |
| - $this->assertEquals(['login_path' => '/bar'], $methodCalls[0][1][0]); |
| 51 | + $this->assertEquals($expectedFailureHandlerOptions, $methodCalls[0][1][0]); |
50 | 52 | } else {
|
51 | 53 | $this->assertCount(0, $methodCalls);
|
| 54 | + $this->assertInstanceOf(ChildDefinition::class, $failureHandler); |
| 55 | + $this->assertEquals('security.authentication.custom_failure_handler', $failureHandler->getParent()); |
| 56 | + $failureHandlerArguments = $failureHandler->getArguments(); |
| 57 | + $this->assertInstanceOf(ChildDefinition::class, $failureHandlerArguments['index_0']); |
| 58 | + $this->assertEquals($serviceId, $failureHandlerArguments['index_0']->getParent()); |
| 59 | + $this->assertEquals($expectedFailureHandlerOptions, $failureHandlerArguments['index_1']); |
52 | 60 | }
|
53 | 61 | }
|
54 | 62 |
|
@@ -80,13 +88,22 @@ public function testDefaultSuccessHandler($serviceId, $defaultHandlerInjection)
|
80 | 88 | $successHandler = $this->container->getDefinition('security.authentication.success_handler.foo.stub');
|
81 | 89 | $methodCalls = $successHandler->getMethodCalls();
|
82 | 90 |
|
| 91 | + $expectedSuccessHandlerOptions = ['default_target_path' => '/bar']; |
| 92 | + $expectedFirewallName = 'foo'; |
83 | 93 | if ($defaultHandlerInjection) {
|
84 | 94 | $this->assertEquals('setOptions', $methodCalls[0][0]);
|
85 |
| - $this->assertEquals(['default_target_path' => '/bar'], $methodCalls[0][1][0]); |
| 95 | + $this->assertEquals($expectedSuccessHandlerOptions, $methodCalls[0][1][0]); |
86 | 96 | $this->assertEquals('setFirewallName', $methodCalls[1][0]);
|
87 |
| - $this->assertEquals(['foo'], $methodCalls[1][1]); |
| 97 | + $this->assertEquals($expectedFirewallName, $methodCalls[1][1][0]); |
88 | 98 | } else {
|
89 | 99 | $this->assertCount(0, $methodCalls);
|
| 100 | + $this->assertInstanceOf(ChildDefinition::class, $successHandler); |
| 101 | + $this->assertEquals('security.authentication.custom_success_handler', $successHandler->getParent()); |
| 102 | + $successHandlerArguments = $successHandler->getArguments(); |
| 103 | + $this->assertInstanceOf(ChildDefinition::class, $successHandlerArguments['index_0']); |
| 104 | + $this->assertEquals($serviceId, $successHandlerArguments['index_0']->getParent()); |
| 105 | + $this->assertEquals($expectedSuccessHandlerOptions, $successHandlerArguments['index_1']); |
| 106 | + $this->assertEquals($expectedFirewallName, $successHandlerArguments['index_2']); |
90 | 107 | }
|
91 | 108 | }
|
92 | 109 |
|
|
0 commit comments