|
19 | 19 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
20 | 20 | use Symfony\Component\DependencyInjection\Definition;
|
21 | 21 | use Symfony\Component\DependencyInjection\Reference;
|
| 22 | +use Symfony\Component\HttpFoundation\RequestMatcher\HostRequestMatcher; |
| 23 | +use Symfony\Component\HttpFoundation\RequestMatcher\MethodRequestMatcher; |
| 24 | +use Symfony\Component\HttpFoundation\RequestMatcher\PathRequestMatcher; |
| 25 | +use Symfony\Component\HttpFoundation\RequestMatcher\PortRequestMatcher; |
22 | 26 | use Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
|
23 | 27 | use Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher;
|
24 | 28 | use Symfony\Component\PasswordHasher\Hasher\PlaintextPasswordHasher;
|
@@ -248,20 +252,27 @@ public function testFirewallRequestMatchers()
|
248 | 252 | foreach ($arguments[1]->getValues() as $reference) {
|
249 | 253 | if ($reference instanceof Reference) {
|
250 | 254 | $definition = $container->getDefinition((string) $reference);
|
251 |
| - $matchers[] = $definition->getArguments(); |
| 255 | + $matchers[] = $definition->getArgument(0); |
252 | 256 | }
|
253 | 257 | }
|
254 | 258 |
|
255 |
| - $this->assertEquals([ |
256 |
| - [ |
257 |
| - '/login', |
258 |
| - ], |
259 |
| - [ |
260 |
| - '/test', |
261 |
| - 'foo\\.example\\.org', |
262 |
| - ['GET', 'POST'], |
263 |
| - ], |
264 |
| - ], $matchers); |
| 259 | + $this->assertCount(2, $matchers); |
| 260 | + |
| 261 | + $this->assertCount(1, $matchers[0]); |
| 262 | + $def = $container->getDefinition((string) $matchers[0][0]); |
| 263 | + $this->assertSame(PathRequestMatcher::class, $def->getClass()); |
| 264 | + $this->assertSame('/login', $def->getArgument(0)); |
| 265 | + |
| 266 | + $this->assertCount(3, $matchers[1]); |
| 267 | + $def = $container->getDefinition((string) $matchers[1][0]); |
| 268 | + $this->assertSame(MethodRequestMatcher::class, $def->getClass()); |
| 269 | + $this->assertSame(['GET', 'POST'], $def->getArgument(0)); |
| 270 | + $def = $container->getDefinition((string) $matchers[1][1]); |
| 271 | + $this->assertSame(PathRequestMatcher::class, $def->getClass()); |
| 272 | + $this->assertSame('/test', $def->getArgument(0)); |
| 273 | + $def = $container->getDefinition((string) $matchers[1][2]); |
| 274 | + $this->assertSame(HostRequestMatcher::class, $def->getClass()); |
| 275 | + $this->assertSame('foo\\.example\\.org', $def->getArgument(0)); |
265 | 276 | }
|
266 | 277 |
|
267 | 278 | public function testUserCheckerAliasIsRegistered()
|
@@ -294,17 +305,23 @@ public function testAccess()
|
294 | 305 | if (1 === $i) {
|
295 | 306 | $this->assertEquals(['ROLE_USER'], $attributes);
|
296 | 307 | $this->assertEquals('https', $channel);
|
297 |
| - $this->assertEquals( |
298 |
| - ['/blog/524', null, ['GET', 'POST'], [], [], null, 8000], |
299 |
| - $requestMatcher->getArguments() |
300 |
| - ); |
| 308 | + $this->assertCount(3, $requestMatcher->getArgument(0)); |
| 309 | + $def = $container->getDefinition((string) $requestMatcher->getArgument(0)[0]); |
| 310 | + $this->assertSame(MethodRequestMatcher::class, $def->getClass()); |
| 311 | + $this->assertSame(['GET', 'POST'], $def->getArgument(0)); |
| 312 | + $def = $container->getDefinition((string) $requestMatcher->getArgument(0)[1]); |
| 313 | + $this->assertSame(PathRequestMatcher::class, $def->getClass()); |
| 314 | + $this->assertSame('/blog/524', $def->getArgument(0)); |
| 315 | + $def = $container->getDefinition((string) $requestMatcher->getArgument(0)[2]); |
| 316 | + $this->assertSame(PortRequestMatcher::class, $def->getClass()); |
| 317 | + $this->assertSame(8000, $def->getArgument(0)); |
301 | 318 | } elseif (2 === $i) {
|
302 | 319 | $this->assertEquals(['IS_AUTHENTICATED_ANONYMOUSLY'], $attributes);
|
303 | 320 | $this->assertNull($channel);
|
304 |
| - $this->assertEquals( |
305 |
| - ['/blog/.*'], |
306 |
| - $requestMatcher->getArguments() |
307 |
| - ); |
| 321 | + $this->assertCount(1, $requestMatcher->getArgument(0)); |
| 322 | + $def = $container->getDefinition((string) $requestMatcher->getArgument(0)[0]); |
| 323 | + $this->assertSame(PathRequestMatcher::class, $def->getClass()); |
| 324 | + $this->assertSame('/blog/.*', $def->getArgument(0)); |
308 | 325 | } elseif (3 === $i) {
|
309 | 326 | $this->assertEquals('IS_AUTHENTICATED_ANONYMOUSLY', $attributes[0]);
|
310 | 327 | $expression = $container->getDefinition((string) $attributes[1])->getArgument(0);
|
|
0 commit comments