|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bundle\SecurityBundle\Tests\Routing; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Bundle\SecurityBundle\Routing\LogoutRouteLoader; |
| 16 | +use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; |
| 17 | +use Symfony\Component\DependencyInjection\Config\ContainerParametersResource; |
| 18 | +use Symfony\Component\Routing\Route; |
| 19 | +use Symfony\Component\Routing\RouteCollection; |
| 20 | + |
| 21 | +class LogoutRouteLoaderTest extends TestCase |
| 22 | +{ |
| 23 | + public function testLoad() |
| 24 | + { |
| 25 | + $logoutPaths = [ |
| 26 | + 'main' => '/logout', |
| 27 | + 'admin' => '/logout', |
| 28 | + ]; |
| 29 | + |
| 30 | + $loader = new LogoutRouteLoader($logoutPaths, 'parameterName'); |
| 31 | + $collection = $loader(); |
| 32 | + |
| 33 | + self::assertInstanceOf(RouteCollection::class, $collection); |
| 34 | + self::assertCount(1, $collection); |
| 35 | + self::assertEquals(new Route('/logout'), $collection->get('_logout_main')); |
| 36 | + self::assertCount(1, $collection->getAliases()); |
| 37 | + self::assertEquals('_logout_admin', $collection->getAlias('_logout_main')->getId()); |
| 38 | + |
| 39 | + $resources = $collection->getResources(); |
| 40 | + self::assertCount(1, $resources); |
| 41 | + |
| 42 | + $resource = reset($resources); |
| 43 | + self::assertInstanceOf(ContainerParametersResource::class, $resource); |
| 44 | + self::assertSame(['parameterName' => $logoutPaths], $resource->getParameters()); |
| 45 | + } |
| 46 | +} |
0 commit comments