You are here

public function KernelTest::testLocateResourceOverrideBundleAndResourcesFolders 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::testLocateResourceOverrideBundleAndResourcesFolders()

File

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

Class

KernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testLocateResourceOverrideBundleAndResourcesFolders() {
  $parent = $this
    ->getBundle(__DIR__ . '/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle');
  $child = $this
    ->getBundle(__DIR__ . '/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle');
  $kernel = $this
    ->getKernel(array(
    'getBundle',
  ));
  $kernel
    ->expects($this
    ->exactly(4))
    ->method('getBundle')
    ->will($this
    ->returnValue(array(
    $child,
    $parent,
  )));
  $this
    ->assertEquals(array(
    __DIR__ . '/Fixtures/Resources/ChildBundle/foo.txt',
    __DIR__ . '/Fixtures/ChildBundle/Resources/foo.txt',
    __DIR__ . '/Fixtures/BaseBundle/Resources/foo.txt',
  ), $kernel
    ->locateResource('@BaseBundle/Resources/foo.txt', __DIR__ . '/Fixtures/Resources', false));
  $this
    ->assertEquals(__DIR__ . '/Fixtures/Resources/ChildBundle/foo.txt', $kernel
    ->locateResource('@BaseBundle/Resources/foo.txt', __DIR__ . '/Fixtures/Resources'));
  try {
    $kernel
      ->locateResource('@BaseBundle/Resources/hide.txt', __DIR__ . '/Fixtures/Resources', false);
    $this
      ->fail('Hidden resources should raise an exception when returning an array of matching paths');
  } catch (\RuntimeException $e) {
  }
  try {
    $kernel
      ->locateResource('@BaseBundle/Resources/hide.txt', __DIR__ . '/Fixtures/Resources', true);
    $this
      ->fail('Hidden resources should raise an exception when returning the first matching path');
  } catch (\RuntimeException $e) {
  }
}