public function KernelTest::testLocateResourceOverrideBundleAndResourcesFolders

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php, line 563

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();
  $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) {
  }
}