4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Tests_ContainerRuntimeLoaderTest extends PHPUnit_Framework_TestCase
17 public function testLoad()
19 $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
20 $container->expects($this->once())->method('has')->with('stdClass')->willReturn(true);
21 $container->expects($this->once())->method('get')->with('stdClass')->willReturn(new stdClass());
23 $loader = new Twig_ContainerRuntimeLoader($container);
25 $this->assertInstanceOf('stdClass', $loader->load('stdClass'));
31 public function testLoadUnknownRuntimeReturnsNull()
33 $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
34 $container->expects($this->once())->method('has')->with('Foo');
35 $container->expects($this->never())->method('get');
37 $loader = new Twig_ContainerRuntimeLoader($container);
38 $this->assertNull($loader->load('Foo'));