Bez popisu

FileLocatorTest.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 Symfony\Component\HttpKernel\Config\FileLocator;
  12. class FileLocatorTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testLocate()
  15. {
  16. $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
  17. $kernel
  18. ->expects($this->atLeastOnce())
  19. ->method('locateResource')
  20. ->with('@BundleName/some/path', null, true)
  21. ->will($this->returnValue('/bundle-name/some/path'));
  22. $locator = new FileLocator($kernel);
  23. $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path'));
  24. $kernel
  25. ->expects($this->never())
  26. ->method('locateResource');
  27. $this->setExpectedException('LogicException');
  28. $locator->locate('/some/path');
  29. }
  30. public function testLocateWithGlobalResourcePath()
  31. {
  32. $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
  33. $kernel
  34. ->expects($this->atLeastOnce())
  35. ->method('locateResource')
  36. ->with('@BundleName/some/path', '/global/resource/path', false);
  37. $locator = new FileLocator($kernel, '/global/resource/path');
  38. $locator->locate('@BundleName/some/path', null, false);
  39. }
  40. }