|
| 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\FrameworkBundle\Tests\Routing; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Psr\Container\ContainerInterface; |
| 16 | +use Symfony\Bundle\FrameworkBundle\Routing\LegacyRouteLoaderContainer; |
| 17 | +use Symfony\Component\DependencyInjection\Container; |
| 18 | + |
| 19 | +/** |
| 20 | + * @group legacy |
| 21 | + */ |
| 22 | +class LegacyRouteLoaderContainerTest extends TestCase |
| 23 | +{ |
| 24 | + /** |
| 25 | + * @var ContainerInterface |
| 26 | + */ |
| 27 | + private $container; |
| 28 | + |
| 29 | + /** |
| 30 | + * @var ContainerInterface |
| 31 | + */ |
| 32 | + private $serviceLocator; |
| 33 | + |
| 34 | + /** |
| 35 | + * @var LegacyRouteLoaderContainer |
| 36 | + */ |
| 37 | + private $legacyRouteLoaderContainer; |
| 38 | + |
| 39 | + /** |
| 40 | + * {@inheritdoc} |
| 41 | + */ |
| 42 | + protected function setUp() |
| 43 | + { |
| 44 | + $this->container = new Container(); |
| 45 | + $this->container->set('foo', new \stdClass()); |
| 46 | + |
| 47 | + $this->serviceLocator = new Container(); |
| 48 | + $this->serviceLocator->set('bar', new \stdClass()); |
| 49 | + |
| 50 | + $this->legacyRouteLoaderContainer = new LegacyRouteLoaderContainer($this->container, $this->serviceLocator); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @expectedDeprecation Registering the service route loader "foo" without tagging it with the "routing.route_loader" tag is deprecated since Symfony 4.4 and will be required in Symfony 5.0. |
| 55 | + */ |
| 56 | + public function testGet() |
| 57 | + { |
| 58 | + $this->assertSame($this->container->get('foo'), $this->legacyRouteLoaderContainer->get('foo')); |
| 59 | + $this->assertSame($this->serviceLocator->get('bar'), $this->legacyRouteLoaderContainer->get('bar')); |
| 60 | + } |
| 61 | + |
| 62 | + public function testHas() |
| 63 | + { |
| 64 | + $this->assertTrue($this->legacyRouteLoaderContainer->has('foo')); |
| 65 | + $this->assertTrue($this->legacyRouteLoaderContainer->has('bar')); |
| 66 | + $this->assertFalse($this->legacyRouteLoaderContainer->has('ccc')); |
| 67 | + } |
| 68 | +} |
0 commit comments