tests/ContainerRuntimeLoaderTest.php
964a51bc
 <?php
 
2119e60c
 namespace Twig\Tests;
 
964a51bc
 /*
  * This file is part of Twig.
  *
  * (c) Fabien Potencier
  *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
 
34bdab4d
 use PHPUnit\Framework\TestCase;
764927d0
 use Psr\Container\ContainerInterface;
90d579e4
 use Twig\RuntimeLoader\ContainerRuntimeLoader;
764927d0
 
34bdab4d
 class ContainerRuntimeLoaderTest extends TestCase
964a51bc
 {
     public function testLoad()
     {
c7b0a459
         $container = $this->createMock(ContainerInterface::class);
964a51bc
         $container->expects($this->once())->method('has')->with('stdClass')->willReturn(true);
a6013120
         $container->expects($this->once())->method('get')->with('stdClass')->willReturn(new \stdClass());
964a51bc
 
90d579e4
         $loader = new ContainerRuntimeLoader($container);
964a51bc
 
         $this->assertInstanceOf('stdClass', $loader->load('stdClass'));
     }
 
     public function testLoadUnknownRuntimeReturnsNull()
     {
c7b0a459
         $container = $this->createMock(ContainerInterface::class);
964a51bc
         $container->expects($this->once())->method('has')->with('Foo');
         $container->expects($this->never())->method('get');
 
90d579e4
         $this->assertNull((new ContainerRuntimeLoader($container))->load('Foo'));
964a51bc
     }
 }