assertEquals($expected, Kernel::stripComments($source));
+ }
+
+ public function testIsClassInActiveBundleFalse()
+ {
+ $kernel = $this->getKernelMockForIsClassInActiveBundleTest();
+
+ $this->assertFalse($kernel->isClassInActiveBundle('Not\In\Active\Bundle'));
+ }
+
+ public function testIsClassInActiveBundleFalseNoNamespace()
+ {
+ $kernel = $this->getKernelMockForIsClassInActiveBundleTest();
+
+ $this->assertFalse($kernel->isClassInActiveBundle('NotNamespacedClass'));
+ }
+
+ public function testIsClassInActiveBundleTrue()
+ {
+ $kernel = $this->getKernelMockForIsClassInActiveBundleTest();
+
+ $this->assertTrue($kernel->isClassInActiveBundle(__NAMESPACE__.'\FooBarBundle\SomeClass'));
+ }
+
+ protected function getKernelMockForIsClassInActiveBundleTest()
+ {
+ $bundle = new FooBarBundle();
+
+ $kernel = $this->getMockBuilder('Symfony\Tests\Component\HttpKernel\KernelForTest')
+ ->disableOriginalConstructor()
+ ->setMethods(array('getBundles'))
+ ->getMock();
+ $kernel->expects($this->once())
+ ->method('getBundles')
+ ->will($this->returnValue(array($bundle)));
+
+ return $kernel;
+ }
+
+ public function testGetRootDir()
+ {
+ $kernel = new KernelForTest('test', true);
+
+ $this->assertEquals(__DIR__, $kernel->getRootDir());
+ }
+
+ public function testGetName()
+ {
+ $kernel = new KernelForTest('test', true);
+
+ $this->assertEquals('HttpKernel', $kernel->getName());
+ }
+
+ public function testSerialize()
+ {
+ $env = 'test_env';
+ $debug = true;
+ $kernel = new KernelForTest($env, $debug);
+
+ $expected = serialize(array($env, $debug));
+ $this->assertEquals($expected, $kernel->serialize());
+ }
+
/**
* @expectedException \InvalidArgumentException
*/
@@ -241,21 +527,21 @@ public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWith
{
$fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName');
$barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName');
-
+
$kernel = $this->getKernel();
$kernel
->expects($this->once())
->method('registerBundles')
->will($this->returnValue(array($fooBundle, $barBundle)))
;
- $kernel->initializeBundles();
+ $kernel->initializeBundles();
}
protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null)
{
$bundle = $this
->getMockBuilder('Symfony\Tests\Component\HttpKernel\BundleForTest')
- ->setMethods(array('getNormalizedPath', 'getParent', 'getName'))
+ ->setMethods(array('getPath', 'getParent', 'getName'))
->disableOriginalConstructor()
;
@@ -273,16 +559,16 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
$bundle
->expects($this->any())
- ->method('getNormalizedPath')
+ ->method('getPath')
->will($this->returnValue(strtr($dir, '\\', '/')))
;
-
+
$bundle
->expects($this->any())
->method('getParent')
->will($this->returnValue($parent))
;
-
+
return $bundle;
}
@@ -315,6 +601,7 @@ public function getBundleMap()
public function registerRootDir()
{
+ return __DIR__;
}
public function registerBundles()
@@ -333,9 +620,24 @@ public function initializeBundles()
{
parent::initializeBundles();
}
+
+ public function isBooted()
+ {
+ return $this->booted;
+ }
+
+ public function setIsBooted($value)
+ {
+ $this->booted = (bool) $value;
+ }
}
abstract class BundleForTest implements BundleInterface
{
// We can not extend Symfony\Component\HttpKernel\Bundle\Bundle as we want to mock getName() which is final
-}
\ No newline at end of file
+}
+
+class FooBarBundle extends Bundle
+{
+ // We need a full namespaced bundle instance to test isClassInActiveBundle
+}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy