|
@@ -12,6 +12,7 @@
|
|
namespace Symfony\Tests\Component\HttpKernel;
|
|
namespace Symfony\Tests\Component\HttpKernel;
|
|
|
|
|
|
use Symfony\Component\HttpKernel\Kernel;
|
|
use Symfony\Component\HttpKernel\Kernel;
|
|
|
|
+use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
|
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
|
use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
|
|
|
|
|
|
class KernelTest extends \PHPUnit_Framework_TestCase
|
|
class KernelTest extends \PHPUnit_Framework_TestCase
|
|
@@ -167,7 +168,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
|
$kernel
|
|
$kernel
|
|
->expects($this->once())
|
|
->expects($this->once())
|
|
->method('registerBundles')
|
|
->method('registerBundles')
|
|
- ->will($this->returnValue(array($parent, $grandparent, $child)))
|
|
|
|
|
|
+ ->will($this->returnValue(array($grandparent, $parent, $child)))
|
|
;
|
|
;
|
|
|
|
|
|
$kernel->initializeBundles();
|
|
$kernel->initializeBundles();
|
|
@@ -194,6 +195,27 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
|
$kernel->initializeBundles();
|
|
$kernel->initializeBundles();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function testInitializeBundlesSupportsArbitaryBundleRegistrationOrder()
|
|
|
|
+ {
|
|
|
|
+ $grandparent = $this->getBundle(null, null, 'GrandParentCCundle');
|
|
|
|
+ $parent = $this->getBundle(null, 'GrandParentCCundle', 'ParentCCundle');
|
|
|
|
+ $child = $this->getBundle(null, 'ParentCCundle', 'ChildCCundle');
|
|
|
|
+
|
|
|
|
+ $kernel = $this->getKernel();
|
|
|
|
+ $kernel
|
|
|
|
+ ->expects($this->once())
|
|
|
|
+ ->method('registerBundles')
|
|
|
|
+ ->will($this->returnValue(array($parent, $grandparent, $child)))
|
|
|
|
+ ;
|
|
|
|
+
|
|
|
|
+ $kernel->initializeBundles();
|
|
|
|
+
|
|
|
|
+ $map = $kernel->getBundleMap();
|
|
|
|
+ $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCCundle']);
|
|
|
|
+ $this->assertEquals(array($child, $parent), $map['ParentCCundle']);
|
|
|
|
+ $this->assertEquals(array($child), $map['ChildCCundle']);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @expectedException \LogicException
|
|
* @expectedException \LogicException
|
|
*/
|
|
*/
|
|
@@ -232,7 +254,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
|
protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null)
|
|
protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null)
|
|
{
|
|
{
|
|
$bundle = $this
|
|
$bundle = $this
|
|
- ->getMockBuilder('Symfony\Tests\Component\HttpKernel\KernelForTest')
|
|
|
|
|
|
+ ->getMockBuilder('Symfony\Tests\Component\HttpKernel\BundleForTest')
|
|
->setMethods(array('getPath', 'getParent', 'getName'))
|
|
->setMethods(array('getPath', 'getParent', 'getName'))
|
|
->disableOriginalConstructor()
|
|
->disableOriginalConstructor()
|
|
;
|
|
;
|
|
@@ -241,7 +263,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
|
$bundle->setMockClassName($className);
|
|
$bundle->setMockClassName($className);
|
|
}
|
|
}
|
|
|
|
|
|
- $bundle = $bundle->getMock();
|
|
|
|
|
|
+ $bundle = $bundle->getMockForAbstractClass();
|
|
|
|
|
|
$bundle
|
|
$bundle
|
|
->expects($this->any())
|
|
->expects($this->any())
|
|
@@ -312,3 +334,8 @@ class KernelForTest extends Kernel
|
|
parent::initializeBundles();
|
|
parent::initializeBundles();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+abstract class BundleForTest implements BundleInterface
|
|
|
|
+{
|
|
|
|
+ // We can not extend Symfony\Component\HttpKernel\Bundle\Bundle as we want to mock getName() which is final
|
|
|
|
+}
|