4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\HttpKernel\Bundle\BundleInterface;
17 use Symfony\Component\HttpKernel\Config\EnvParametersResource;
18 use Symfony\Component\HttpKernel\Kernel;
19 use Symfony\Component\HttpKernel\HttpKernelInterface;
20 use Symfony\Component\HttpFoundation\Request;
21 use Symfony\Component\HttpFoundation\Response;
22 use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest;
23 use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
24 use Symfony\Component\HttpKernel\Tests\Fixtures\FooBarBundle;
26 class KernelTest extends TestCase
28 public function testConstructor()
32 $kernel = new KernelForTest($env, $debug);
34 $this->assertEquals($env, $kernel->getEnvironment());
35 $this->assertEquals($debug, $kernel->isDebug());
36 $this->assertFalse($kernel->isBooted());
37 $this->assertLessThanOrEqual(microtime(true), $kernel->getStartTime());
38 $this->assertNull($kernel->getContainer());
41 public function testClone()
45 $kernel = new KernelForTest($env, $debug);
47 $clone = clone $kernel;
49 $this->assertEquals($env, $clone->getEnvironment());
50 $this->assertEquals($debug, $clone->isDebug());
51 $this->assertFalse($clone->isBooted());
52 $this->assertLessThanOrEqual(microtime(true), $clone->getStartTime());
53 $this->assertNull($clone->getContainer());
56 public function testBootInitializesBundlesAndContainer()
58 $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer'));
59 $kernel->expects($this->once())
60 ->method('initializeBundles');
61 $kernel->expects($this->once())
62 ->method('initializeContainer');
67 public function testBootSetsTheContainerToTheBundles()
69 $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
70 $bundle->expects($this->once())
71 ->method('setContainer');
73 $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'getBundles'));
74 $kernel->expects($this->once())
75 ->method('getBundles')
76 ->will($this->returnValue(array($bundle)));
81 public function testBootSetsTheBootedFlagToTrue()
83 // use test kernel to access isBooted()
84 $kernel = $this->getKernelForTest(array('initializeBundles', 'initializeContainer'));
87 $this->assertTrue($kernel->isBooted());
90 public function testClassCacheIsLoaded()
92 $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache'));
93 $kernel->loadClassCache('name', '.extension');
94 $kernel->expects($this->once())
95 ->method('doLoadClassCache')
96 ->with('name', '.extension');
101 public function testClassCacheIsNotLoadedByDefault()
103 $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache'));
104 $kernel->expects($this->never())
105 ->method('doLoadClassCache');
110 public function testClassCacheIsNotLoadedWhenKernelIsNotBooted()
112 $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache'));
113 $kernel->loadClassCache();
114 $kernel->expects($this->never())
115 ->method('doLoadClassCache');
118 public function testEnvParametersResourceIsAdded()
120 $container = new ContainerBuilder();
121 $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
122 ->disableOriginalConstructor()
123 ->setMethods(array('getContainerBuilder', 'prepareContainer', 'getCacheDir', 'getLogDir'))
125 $kernel->expects($this->any())
126 ->method('getContainerBuilder')
127 ->will($this->returnValue($container));
128 $kernel->expects($this->any())
129 ->method('prepareContainer')
130 ->will($this->returnValue(null));
131 $kernel->expects($this->any())
132 ->method('getCacheDir')
133 ->will($this->returnValue(sys_get_temp_dir()));
134 $kernel->expects($this->any())
135 ->method('getLogDir')
136 ->will($this->returnValue(sys_get_temp_dir()));
138 $reflection = new \ReflectionClass(get_class($kernel));
139 $method = $reflection->getMethod('buildContainer');
140 $method->setAccessible(true);
141 $method->invoke($kernel);
144 foreach ($container->getResources() as $resource) {
145 if ($resource instanceof EnvParametersResource) {
151 $this->assertTrue($found);
154 public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce()
156 $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer'));
157 $kernel->expects($this->once())
158 ->method('initializeBundles');
164 public function testShutdownCallsShutdownOnAllBundles()
166 $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
167 $bundle->expects($this->once())
168 ->method('shutdown');
170 $kernel = $this->getKernel(array(), array($bundle));
176 public function testShutdownGivesNullContainerToAllBundles()
178 $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
179 $bundle->expects($this->at(3))
180 ->method('setContainer')
183 $kernel = $this->getKernel(array('getBundles'));
184 $kernel->expects($this->any())
185 ->method('getBundles')
186 ->will($this->returnValue(array($bundle)));
192 public function testHandleCallsHandleOnHttpKernel()
194 $type = HttpKernelInterface::MASTER_REQUEST;
196 $request = new Request();
198 $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel')
199 ->disableOriginalConstructor()
202 ->expects($this->once())
204 ->with($request, $type, $catch);
206 $kernel = $this->getKernel(array('getHttpKernel'));
207 $kernel->expects($this->once())
208 ->method('getHttpKernel')
209 ->will($this->returnValue($httpKernelMock));
211 $kernel->handle($request, $type, $catch);
214 public function testHandleBootsTheKernel()
216 $type = HttpKernelInterface::MASTER_REQUEST;
218 $request = new Request();
220 $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel')
221 ->disableOriginalConstructor()
224 $kernel = $this->getKernel(array('getHttpKernel', 'boot'));
225 $kernel->expects($this->once())
226 ->method('getHttpKernel')
227 ->will($this->returnValue($httpKernelMock));
229 $kernel->expects($this->once())
232 $kernel->handle($request, $type, $catch);
235 public function testStripComments()
240 $string = 'string should not be modified';
242 $string = 'string should not be
250 Heredoc should not be modified {$a[1+$b]}
258 Nowdoc should not be modified
264 * some class comments to strip
269 * some method comments to strip
271 public function doStuff()
279 $string = 'string should not be modified';
280 $string = 'string should not be
286 Heredoc should not be modified {$a[1+$b]}
293 Nowdoc should not be modified
299 public function doStuff()
305 $output = Kernel::stripComments($source);
307 // Heredocs are preserved, making the output mixing Unix and Windows line
308 // endings, switching to "\n" everywhere on Windows to avoid failure.
309 if ('\\' === DIRECTORY_SEPARATOR) {
310 $expected = str_replace("\r\n", "\n", $expected);
311 $output = str_replace("\r\n", "\n", $output);
314 $this->assertEquals($expected, $output);
320 public function testLegacyIsClassInActiveBundleFalse()
322 $kernel = $this->getKernelMockForIsClassInActiveBundleTest();
324 $this->assertFalse($kernel->isClassInActiveBundle('Not\In\Active\Bundle'));
330 public function testLegacyIsClassInActiveBundleFalseNoNamespace()
332 $kernel = $this->getKernelMockForIsClassInActiveBundleTest();
334 $this->assertFalse($kernel->isClassInActiveBundle('NotNamespacedClass'));
340 public function testLegacyIsClassInActiveBundleTrue()
342 $kernel = $this->getKernelMockForIsClassInActiveBundleTest();
344 $this->assertTrue($kernel->isClassInActiveBundle(__NAMESPACE__.'\Fixtures\FooBarBundle\SomeClass'));
347 protected function getKernelMockForIsClassInActiveBundleTest()
349 $bundle = new FooBarBundle();
351 $kernel = $this->getKernel(array('getBundles'));
352 $kernel->expects($this->once())
353 ->method('getBundles')
354 ->will($this->returnValue(array($bundle)));
359 public function testGetRootDir()
361 $kernel = new KernelForTest('test', true);
363 $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir()));
366 public function testGetName()
368 $kernel = new KernelForTest('test', true);
370 $this->assertEquals('Fixtures', $kernel->getName());
373 public function testOverrideGetName()
375 $kernel = new KernelForOverrideName('test', true);
377 $this->assertEquals('overridden', $kernel->getName());
380 public function testSerialize()
384 $kernel = new KernelForTest($env, $debug);
386 $expected = serialize(array($env, $debug));
387 $this->assertEquals($expected, $kernel->serialize());
391 * @expectedException \InvalidArgumentException
393 public function testLocateResourceThrowsExceptionWhenNameIsNotValid()
395 $this->getKernel()->locateResource('Foo');
399 * @expectedException \RuntimeException
401 public function testLocateResourceThrowsExceptionWhenNameIsUnsafe()
403 $this->getKernel()->locateResource('@FooBundle/../bar');
407 * @expectedException \InvalidArgumentException
409 public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist()
411 $this->getKernel()->locateResource('@FooBundle/config/routing.xml');
415 * @expectedException \InvalidArgumentException
417 public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist()
419 $kernel = $this->getKernel(array('getBundle'));
421 ->expects($this->once())
422 ->method('getBundle')
423 ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'))))
426 $kernel->locateResource('@Bundle1Bundle/config/routing.xml');
429 public function testLocateResourceReturnsTheFirstThatMatches()
431 $kernel = $this->getKernel(array('getBundle'));
433 ->expects($this->once())
434 ->method('getBundle')
435 ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'))))
438 $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt'));
441 public function testLocateResourceReturnsTheFirstThatMatchesWithParent()
443 $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle');
444 $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle');
446 $kernel = $this->getKernel(array('getBundle'));
448 ->expects($this->exactly(2))
449 ->method('getBundle')
450 ->will($this->returnValue(array($child, $parent)))
453 $this->assertEquals(__DIR__.'/Fixtures/Bundle2Bundle/foo.txt', $kernel->locateResource('@ParentAABundle/foo.txt'));
454 $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/bar.txt', $kernel->locateResource('@ParentAABundle/bar.txt'));
457 public function testLocateResourceReturnsAllMatches()
459 $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle');
460 $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle');
462 $kernel = $this->getKernel(array('getBundle'));
464 ->expects($this->once())
465 ->method('getBundle')
466 ->will($this->returnValue(array($child, $parent)))
469 $this->assertEquals(array(
470 __DIR__.'/Fixtures/Bundle2Bundle/foo.txt',
471 __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', ),
472 $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false));
475 public function testLocateResourceReturnsAllMatchesBis()
477 $kernel = $this->getKernel(array('getBundle'));
479 ->expects($this->once())
480 ->method('getBundle')
481 ->will($this->returnValue(array(
482 $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'),
483 $this->getBundle(__DIR__.'/Foobar'),
488 array(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt'),
489 $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false)
493 public function testLocateResourceIgnoresDirOnNonResource()
495 $kernel = $this->getKernel(array('getBundle'));
497 ->expects($this->once())
498 ->method('getBundle')
499 ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'))))
503 __DIR__.'/Fixtures/Bundle1Bundle/foo.txt',
504 $kernel->locateResource('@Bundle1Bundle/foo.txt', __DIR__.'/Fixtures')
508 public function testLocateResourceReturnsTheDirOneForResources()
510 $kernel = $this->getKernel(array('getBundle'));
512 ->expects($this->once())
513 ->method('getBundle')
514 ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle'))))
518 __DIR__.'/Fixtures/Resources/FooBundle/foo.txt',
519 $kernel->locateResource('@FooBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources')
523 public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes()
525 $kernel = $this->getKernel(array('getBundle'));
527 ->expects($this->once())
528 ->method('getBundle')
529 ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle'))))
532 $this->assertEquals(array(
533 __DIR__.'/Fixtures/Resources/Bundle1Bundle/foo.txt',
534 __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt', ),
535 $kernel->locateResource('@Bundle1Bundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false)
539 public function testLocateResourceOverrideBundleAndResourcesFolders()
541 $parent = $this->getBundle(__DIR__.'/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle');
542 $child = $this->getBundle(__DIR__.'/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle');
544 $kernel = $this->getKernel(array('getBundle'));
546 ->expects($this->exactly(4))
547 ->method('getBundle')
548 ->will($this->returnValue(array($child, $parent)))
551 $this->assertEquals(array(
552 __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt',
553 __DIR__.'/Fixtures/ChildBundle/Resources/foo.txt',
554 __DIR__.'/Fixtures/BaseBundle/Resources/foo.txt',
556 $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false)
560 __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt',
561 $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources')
565 $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', false);
566 $this->fail('Hidden resources should raise an exception when returning an array of matching paths');
567 } catch (\RuntimeException $e) {
571 $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', true);
572 $this->fail('Hidden resources should raise an exception when returning the first matching path');
573 } catch (\RuntimeException $e) {
577 public function testLocateResourceOnDirectories()
579 $kernel = $this->getKernel(array('getBundle'));
581 ->expects($this->exactly(2))
582 ->method('getBundle')
583 ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle'))))
587 __DIR__.'/Fixtures/Resources/FooBundle/',
588 $kernel->locateResource('@FooBundle/Resources/', __DIR__.'/Fixtures/Resources')
591 __DIR__.'/Fixtures/Resources/FooBundle',
592 $kernel->locateResource('@FooBundle/Resources', __DIR__.'/Fixtures/Resources')
595 $kernel = $this->getKernel(array('getBundle'));
597 ->expects($this->exactly(2))
598 ->method('getBundle')
599 ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle'))))
603 __DIR__.'/Fixtures/Bundle1Bundle/Resources/',
604 $kernel->locateResource('@Bundle1Bundle/Resources/')
607 __DIR__.'/Fixtures/Bundle1Bundle/Resources',
608 $kernel->locateResource('@Bundle1Bundle/Resources')
612 public function testInitializeBundles()
614 $parent = $this->getBundle(null, null, 'ParentABundle');
615 $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle');
617 // use test kernel so we can access getBundleMap()
618 $kernel = $this->getKernelForTest(array('registerBundles'));
620 ->expects($this->once())
621 ->method('registerBundles')
622 ->will($this->returnValue(array($parent, $child)))
626 $map = $kernel->getBundleMap();
627 $this->assertEquals(array($child, $parent), $map['ParentABundle']);
630 public function testInitializeBundlesSupportInheritanceCascade()
632 $grandparent = $this->getBundle(null, null, 'GrandParentBBundle');
633 $parent = $this->getBundle(null, 'GrandParentBBundle', 'ParentBBundle');
634 $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle');
636 // use test kernel so we can access getBundleMap()
637 $kernel = $this->getKernelForTest(array('registerBundles'));
639 ->expects($this->once())
640 ->method('registerBundles')
641 ->will($this->returnValue(array($grandparent, $parent, $child)))
645 $map = $kernel->getBundleMap();
646 $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentBBundle']);
647 $this->assertEquals(array($child, $parent), $map['ParentBBundle']);
648 $this->assertEquals(array($child), $map['ChildBBundle']);
652 * @expectedException \LogicException
653 * @expectedExceptionMessage Bundle "ChildCBundle" extends bundle "FooBar", which is not registered.
655 public function testInitializeBundlesThrowsExceptionWhenAParentDoesNotExists()
657 $child = $this->getBundle(null, 'FooBar', 'ChildCBundle');
658 $kernel = $this->getKernel(array(), array($child));
662 public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder()
664 $grandparent = $this->getBundle(null, null, 'GrandParentCBundle');
665 $parent = $this->getBundle(null, 'GrandParentCBundle', 'ParentCBundle');
666 $child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle');
668 // use test kernel so we can access getBundleMap()
669 $kernel = $this->getKernelForTest(array('registerBundles'));
671 ->expects($this->once())
672 ->method('registerBundles')
673 ->will($this->returnValue(array($parent, $grandparent, $child)))
677 $map = $kernel->getBundleMap();
678 $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCBundle']);
679 $this->assertEquals(array($child, $parent), $map['ParentCBundle']);
680 $this->assertEquals(array($child), $map['ChildCBundle']);
684 * @expectedException \LogicException
685 * @expectedExceptionMessage Bundle "ParentCBundle" is directly extended by two bundles "ChildC2Bundle" and "ChildC1Bundle".
687 public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtendedByTwoBundles()
689 $parent = $this->getBundle(null, null, 'ParentCBundle');
690 $child1 = $this->getBundle(null, 'ParentCBundle', 'ChildC1Bundle');
691 $child2 = $this->getBundle(null, 'ParentCBundle', 'ChildC2Bundle');
693 $kernel = $this->getKernel(array(), array($parent, $child1, $child2));
698 * @expectedException \LogicException
699 * @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName"
701 public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName()
703 $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName');
704 $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName');
706 $kernel = $this->getKernel(array(), array($fooBundle, $barBundle));
711 * @expectedException \LogicException
712 * @expectedExceptionMessage Bundle "CircularRefBundle" can not extend itself.
714 public function testInitializeBundleThrowsExceptionWhenABundleExtendsItself()
716 $circularRef = $this->getBundle(null, 'CircularRefBundle', 'CircularRefBundle');
718 $kernel = $this->getKernel(array(), array($circularRef));
722 public function testTerminateReturnsSilentlyIfKernelIsNotBooted()
724 $kernel = $this->getKernel(array('getHttpKernel'));
725 $kernel->expects($this->never())
726 ->method('getHttpKernel');
728 $kernel->terminate(Request::create('/'), new Response());
731 public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
733 // does not implement TerminableInterface
734 $httpKernel = new TestKernel();
736 $kernel = $this->getKernel(array('getHttpKernel'));
737 $kernel->expects($this->once())
738 ->method('getHttpKernel')
739 ->willReturn($httpKernel);
742 $kernel->terminate(Request::create('/'), new Response());
744 $this->assertFalse($httpKernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface');
746 // implements TerminableInterface
747 $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel')
748 ->disableOriginalConstructor()
749 ->setMethods(array('terminate'))
753 ->expects($this->once())
754 ->method('terminate');
756 $kernel = $this->getKernel(array('getHttpKernel'));
757 $kernel->expects($this->exactly(2))
758 ->method('getHttpKernel')
759 ->will($this->returnValue($httpKernelMock));
762 $kernel->terminate(Request::create('/'), new Response());
765 public function testKernelRootDirNameStartingWithANumber()
767 $dir = __DIR__.'/Fixtures/123';
768 require_once $dir.'/Kernel123.php';
769 $kernel = new \Symfony\Component\HttpKernel\Tests\Fixtures\_123\Kernel123('dev', true);
770 $this->assertEquals('_123', $kernel->getName());
774 * Returns a mock for the BundleInterface.
776 * @return BundleInterface
778 protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null)
781 ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')
782 ->setMethods(array('getPath', 'getParent', 'getName'))
783 ->disableOriginalConstructor()
787 $bundle->setMockClassName($className);
790 $bundle = $bundle->getMockForAbstractClass();
793 ->expects($this->any())
795 ->will($this->returnValue(null === $bundleName ? get_class($bundle) : $bundleName))
799 ->expects($this->any())
801 ->will($this->returnValue($dir))
805 ->expects($this->any())
806 ->method('getParent')
807 ->will($this->returnValue($parent))
814 * Returns a mock for the abstract kernel.
816 * @param array $methods Additional methods to mock (besides the abstract ones)
817 * @param array $bundles Bundles to register
821 protected function getKernel(array $methods = array(), array $bundles = array())
823 $methods[] = 'registerBundles';
826 ->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
827 ->setMethods($methods)
828 ->setConstructorArgs(array('test', false))
829 ->getMockForAbstractClass()
831 $kernel->expects($this->any())
832 ->method('registerBundles')
833 ->will($this->returnValue($bundles))
835 $p = new \ReflectionProperty($kernel, 'rootDir');
836 $p->setAccessible(true);
837 $p->setValue($kernel, __DIR__.'/Fixtures');
842 protected function getKernelForTest(array $methods = array())
844 $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
845 ->setConstructorArgs(array('test', false))
846 ->setMethods($methods)
848 $p = new \ReflectionProperty($kernel, 'rootDir');
849 $p->setAccessible(true);
850 $p->setValue($kernel, __DIR__.'/Fixtures');
856 class TestKernel implements HttpKernelInterface
858 public $terminateCalled = false;
860 public function terminate()
862 $this->terminateCalled = true;
865 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)