|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\HttpKernel\Tests\Config; |
| 13 | + |
| 14 | +use Symfony\Component\HttpKernel\Config\FileLocator; |
| 15 | +use Symfony\Component\HttpKernel\KernelInterface; |
| 16 | + |
| 17 | +class FileLocatorTest extends \PHPUnit_Framework_TestCase |
| 18 | +{ |
| 19 | + |
| 20 | + /** @var KernelInterface */ |
| 21 | + private $kernel; |
| 22 | + |
| 23 | + public function setUp() |
| 24 | + { |
| 25 | + $this->kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); |
| 26 | + } |
| 27 | + |
| 28 | + public function tearDown() |
| 29 | + { |
| 30 | + $this->kernel = null; |
| 31 | + } |
| 32 | + |
| 33 | + public function testLocate() |
| 34 | + { |
| 35 | + $this->kernel |
| 36 | + ->expects($this->atLeastOnce()) |
| 37 | + ->method('locateResource') |
| 38 | + ->with('@BundleName/some/path', null, true) |
| 39 | + ->will($this->returnValue('/bundle-name/some/path')); |
| 40 | + $locator = new FileLocator($this->kernel); |
| 41 | + $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path')); |
| 42 | + |
| 43 | + $this->kernel |
| 44 | + ->expects($this->never()) |
| 45 | + ->method('locateResource'); |
| 46 | + $this->setExpectedException('LogicException'); |
| 47 | + $locator->locate('/some/path'); |
| 48 | + } |
| 49 | + |
| 50 | + public function testLocateWithGlobalResourcePath() |
| 51 | + { |
| 52 | + $this->kernel |
| 53 | + ->expects($this->atLeastOnce()) |
| 54 | + ->method('locateResource') |
| 55 | + ->with('@BundleName/some/path', '/global/resource/path', false); |
| 56 | + |
| 57 | + $locator = new FileLocator($this->kernel, '/global/resource/path'); |
| 58 | + $locator->locate('@BundleName/some/path', null, false); |
| 59 | + } |
| 60 | + |
| 61 | +} |
0 commit comments