8000 [HttpKernel] fixed unit tests when using phpunit.phar · matthieuauger/symfony@0edb192 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0edb192

Browse files
committed
[HttpKernel] fixed unit tests when using phpunit.phar
1 parent 3e7da99 commit 0edb192

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,7 @@ public function testBootSetsTheContainerToTheBundles()
7777
public function testBootSetsTheBootedFlagToTrue()
7878
{
7979
// use test kernel to access isBooted()
80-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
81-
->setConstructorArgs(array('test', false))
82-
->setMethods(array('initializeBundles', 'initializeContainer'))
83-
->getMock();
84-
80+
$kernel = $this->getKernelForTest(array('initializeBundles', 'initializeContainer'));
8581
$kernel->boot();
8682

8783
$this->assertTrue($kernel->isBooted());
@@ -575,12 +571,7 @@ public function testInitializeBundles()
575571
$child = $this->getBundle(null, 'ParentABundle', 'ChildABundle');
576572

577573
// use test kernel so we can access getBundleMap()
578-
$kernel = $this
579-
->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
580-
->setMethods(array('registerBundles'))
581-
->setConstructorArgs(array('test', false))
582-
->getMock()
583-
;
574+
$kernel = $this->getKernelForTest(array('registerBundles'));
584575
$kernel
585576
->expects($this->once())
586577
->method('registerBundles')
@@ -599,18 +590,12 @@ public function testInitializeBundlesSupportInheritanceCascade()
599590
$child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle');
600591

601592
// use test kernel so we can access getBundleMap()
602-
$kernel = $this
603-
->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
604-
->setMethods(array('registerBundles'))
605-
->setConstructorArgs(array('test', false))
606-
->getMock()
607-
;
593+
$kernel = $this->getKernelForTest(array('registerBundles'));
608594
$kernel
609595
->expects($this->once())
610596
->method('registerBundles')
611597
->will($this->returnValue(array($grandparent, $parent, $child)))
612598
;
613-
614599
$kernel->boot();
615600

616601
$map = $kernel->getBundleMap();
@@ -637,18 +622,12 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder()
637622
$child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle');
638623

639624
// use test kernel so we can access getBundleMap()
640-
$kernel = $this
641-
->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
642-
->setMethods(array('registerBundles'))
643-
->setConstructorArgs(array('test', false))
644-
->getMock()
645-
;
625+
$kernel = $this->getKernelForTest(array('registerBundles'));
646626
$kernel
647627
->expects($this->once())
648628
->method('registerBundles')
649629
->will($this->returnValue(array($parent, $grandparent, $child)))
650630
;
651-
652631
$kernel->boot();
653632

654633
$map = $kernel->getBundleMap();
@@ -793,17 +772,34 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
793772
*/
794773
protected function getKernel(array $methods = array(), array $bundles = array())
795774
{
775+
$methods[] = 'registerBundles';
776+
796777
$kernel = $this
797778
->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
798779
->setMethods($methods)
799780
->setConstructorArgs(array('test', false))
800781
->getMockForAbstractClass()
801782
;
802-
803783
$kernel->expects($this->any())
804784
->method('registerBundles')
805785
->will($this->returnValue($bundles))
806786
;
787+
$p = new \ReflectionProperty($kernel, 'rootDir');
788+
$p->setAccessible(true);
789+
$p->setValue($kernel, __DIR__.'/Fixtures');
790+
791+
return $kernel;
792+
}
793+
794+
protected function getKernelForTest(array $methods = array())
795+
{
796+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
797+
->setConstructorArgs(array('test', false))
798+
->setMethods($methods)
799+
->getMock();
800+
$p = new \ReflectionProperty($kernel, 'rootDir');
801+
$p->setAccessible(true);
802+
$p->setValue($kernel, __DIR__.'/Fixtures');
807803

808804
return $kernel;
809805
}

0 commit comments

Comments
 (0)
0