Browse Source

[HttpKernel] Fix the case where no resource is found

Victor Berchet 14 years ago
parent
commit
ceb2c976de

+ 1 - 0
src/Symfony/Component/HttpKernel/Kernel.php

@@ -243,6 +243,7 @@ abstract class Kernel implements KernelInterface
         $overridePath = substr($path, 9);
         $resourceBundle = null;
         $bundles = $this->getBundle($bundleName, false);
+        $files = array();
 
         foreach ($bundles as $bundle) {
             if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) {

+ 15 - 0
tests/Symfony/Tests/Component/HttpKernel/KernelTest.php

@@ -327,6 +327,21 @@ EOF;
         $this->getKernelForInvalidLocateResource()->locateResource('@FooBundle/config/routing.xml');
     }
 
+    /**
+     * @expectedException \InvalidArgumentException
+     */
+    public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist()
+    {
+        $kernel = $this->getKernel();
+        $kernel
+            ->expects($this->once())
+            ->method('getBundle')
+            ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'))))
+        ;
+
+        $kernel->locateResource('@Bundle1Bundle/config/routing.xml');
+    }
+   
     public function testLocateResourceReturnsTheFirstThatMatches()
     {
         $kernel = $this->getKernel();