|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\TwigBundle\Tests;
|
13 | 13 |
|
| 14 | +use Psr\Container\ContainerInterface; |
14 | 15 | use Psr\Log\LoggerInterface;
|
15 |
| -use Symfony\Component\DependencyInjection\ContainerInterface; |
16 | 16 | use Symfony\Bundle\TwigBundle\ContainerAwareRuntimeLoader;
|
17 | 17 |
|
18 | 18 | class ContainerAwareRuntimeLoaderTest extends TestCase
|
19 | 19 | {
|
20 | 20 | public function testLoad()
|
21 | 21 | {
|
22 | 22 | $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
23 |
| - $container->expects($this->once())->method('get')->with('foo'); |
| 23 | + $container->expects($this->once())->method('has')->with('FooClass')->willReturn(true); |
| 24 | + $container->expects($this->once())->method('get')->with('FooClass'); |
24 | 25 |
|
25 |
| - $loader = new ContainerAwareRuntimeLoader($container, array( |
26 |
| - 'FooClass' => 'foo', |
27 |
| - )); |
| 26 | + $loader = new ContainerAwareRuntimeLoader($container); |
28 | 27 | $loader->load('FooClass');
|
29 | 28 | }
|
30 | 29 |
|
31 | 30 | public function testLoadWithoutAMatch()
|
32 | 31 | {
|
33 | 32 | $logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
|
34 | 33 | $logger->expects($this->once())->method('warning')->with('Class "BarClass" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.');
|
35 |
| - $loader = new ContainerAwareRuntimeLoader($this->getMockBuilder(ContainerInterface::class)->getMock(), array(), $logger); |
| 34 | + $loader = new ContainerAwareRuntimeLoader($this->getMockBuilder(ContainerInterface::class)->getMock(), $logger); |
36 | 35 | $this->assertNull($loader->load('BarClass'));
|
37 | 36 | }
|
| 37 | + |
| 38 | + /** |
| 39 | + * @group legacy |
| 40 | + * @expectedDeprecation The second argument of Symfony\Bundle\TwigBundle\ContainerAwareRuntimeLoader::__construct() is deprecated since version 3.3 and will be removed, passing something else than a Psr\Log\LoggerInterface instance will trigger an error in 4.0. |
| 41 | + */ |
| 42 | + public function testSecondConstructorArgumentIsDeprecated() |
| 43 | + { |
| 44 | + $loader = new ContainerAwareRuntimeLoader($this->getMockBuilder(ContainerInterface::class)->getMock(), array()); |
| 45 | + } |
38 | 46 | }
|
0 commit comments