FileLocatorTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Tests\Config;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\HttpKernel\Config\FileLocator;
  13. class FileLocatorTest extends TestCase
  14. {
  15. public function testLocate()
  16. {
  17. $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
  18. $kernel
  19. ->expects($this->atLeastOnce())
  20. ->method('locateResource')
  21. ->with('@BundleName/some/path', null, true)
  22. ->will($this->returnValue('/bundle-name/some/path'));
  23. $locator = new FileLocator($kernel);
  24. $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path'));
  25. $kernel
  26. ->expects($this->never())
  27. ->method('locateResource');
  28. $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
  29. $locator->locate('/some/path');
  30. }
  31. public function testLocateWithGlobalResourcePath()
  32. {
  33. $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
  34. $kernel
  35. ->expects($this->atLeastOnce())
  36. ->method('locateResource')
  37. ->with('@BundleName/some/path', '/global/resource/path', false);
  38. $locator = new FileLocator($kernel, '/global/resource/path');
  39. $locator->locate('@BundleName/some/path', null, false);
  40. }
  41. }