You are here

public function KernelTest::testEnvParametersResourceIsAdded in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/KernelTest.php \Symfony\Component\HttpKernel\Tests\KernelTest::testEnvParametersResourceIsAdded()

File

vendor/symfony/http-kernel/Tests/KernelTest.php, line 117

Class

KernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testEnvParametersResourceIsAdded() {
  $container = new ContainerBuilder();
  $kernel = $this
    ->getMockBuilder('Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\KernelForTest')
    ->disableOriginalConstructor()
    ->setMethods(array(
    'getContainerBuilder',
    'prepareContainer',
    'getCacheDir',
    'getLogDir',
  ))
    ->getMock();
  $kernel
    ->expects($this
    ->any())
    ->method('getContainerBuilder')
    ->will($this
    ->returnValue($container));
  $kernel
    ->expects($this
    ->any())
    ->method('prepareContainer')
    ->will($this
    ->returnValue(null));
  $kernel
    ->expects($this
    ->any())
    ->method('getCacheDir')
    ->will($this
    ->returnValue(sys_get_temp_dir()));
  $kernel
    ->expects($this
    ->any())
    ->method('getLogDir')
    ->will($this
    ->returnValue(sys_get_temp_dir()));
  $reflection = new \ReflectionClass(get_class($kernel));
  $method = $reflection
    ->getMethod('buildContainer');
  $method
    ->setAccessible(true);
  $method
    ->invoke($kernel);
  $found = false;
  foreach ($container
    ->getResources() as $resource) {
    if ($resource instanceof EnvParametersResource) {
      $found = true;
      break;
    }
  }
  $this
    ->assertTrue($found);
}