[HttpKernel] tweaked previous merge

This commit is contained in:
Fabien Potencier 2013-04-07 17:51:26 +02:00
parent 171aa1d670
commit 12b7073607
2 changed files with 8 additions and 22 deletions

View File

@ -34,7 +34,7 @@ class FileLocator extends BaseFileLocator
public function __construct(KernelInterface $kernel, $path = null, array $paths = array()) public function __construct(KernelInterface $kernel, $path = null, array $paths = array())
{ {
$this->kernel = $kernel; $this->kernel = $kernel;
if(null !== $path) { if (null !== $path) {
$this->path = $path; $this->path = $path;
$paths[] = $path; $paths[] = $path;
} }

View File

@ -12,35 +12,21 @@
namespace Symfony\Component\HttpKernel\Tests\Config; namespace Symfony\Component\HttpKernel\Tests\Config;
use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\Config\FileLocator;
use Symfony\Component\HttpKernel\KernelInterface;
class FileLocatorTest extends \PHPUnit_Framework_TestCase class FileLocatorTest extends \PHPUnit_Framework_TestCase
{ {
/** @var KernelInterface */
private $kernel;
public function setUp()
{
$this->kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
}
public function tearDown()
{
$this->kernel = null;
}
public function testLocate() public function testLocate()
{ {
$this->kernel $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('locateResource') ->method('locateResource')
->with('@BundleName/some/path', null, true) ->with('@BundleName/some/path', null, true)
->will($this->returnValue('/bundle-name/some/path')); ->will($this->returnValue('/bundle-name/some/path'));
$locator = new FileLocator($this->kernel); $locator = new FileLocator($kernel);
$this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path')); $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path'));
$this->kernel $kernel
->expects($this->never()) ->expects($this->never())
->method('locateResource'); ->method('locateResource');
$this->setExpectedException('LogicException'); $this->setExpectedException('LogicException');
@ -49,13 +35,13 @@ class FileLocatorTest extends \PHPUnit_Framework_TestCase
public function testLocateWithGlobalResourcePath() public function testLocateWithGlobalResourcePath()
{ {
$this->kernel $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('locateResource') ->method('locateResource')
->with('@BundleName/some/path', '/global/resource/path', false); ->with('@BundleName/some/path', '/global/resource/path', false);
$locator = new FileLocator($this->kernel, '/global/resource/path'); $locator = new FileLocator($kernel, '/global/resource/path');
$locator->locate('@BundleName/some/path', null, false); $locator->locate('@BundleName/some/path', null, false);
} }
} }