@@ -77,11 +77,7 @@ public function testBootSetsTheContainerToTheBundles()
77
77
public function testBootSetsTheBootedFlagToTrue ()
78
78
{
79
79
// 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 ' ));
85
81
$ kernel ->boot ();
86
82
87
83
$ this ->assertTrue ($ kernel ->isBooted ());
@@ -575,12 +571,7 @@ public function testInitializeBundles()
575
571
$ child = $ this ->getBundle (null , 'ParentABundle ' , 'ChildABundle ' );
576
572
577
573
// 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 ' ));
584
575
$ kernel
585
576
->expects ($ this ->once ())
586
577
->method ('registerBundles ' )
@@ -599,18 +590,12 @@ public function testInitializeBundlesSupportInheritanceCascade()
599
590
$ child = $ this ->getBundle (null , 'ParentBBundle ' , 'ChildBBundle ' );
600
591
601
592
// 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 ' ));
608
594
$ kernel
609
595
->expects ($ this ->once ())
610
596
->method ('registerBundles ' )
611
597
->will ($ this ->returnValue (array ($ grandparent , $ parent , $ child )))
612
598
;
613
-
614
599
$ kernel ->boot ();
615
600
616
601
$ map = $ kernel ->getBundleMap ();
@@ -637,18 +622,12 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder()
637
622
$ child = $ this ->getBundle (null , 'ParentCBundle ' , 'ChildCBundle ' );
638
623
639
624
// 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 ' ));
646
626
$ kernel
647
627
->expects ($ this ->once ())
648
628
->method ('registerBundles ' )
649
629
->will ($ this ->returnValue (array ($ parent , $ grandparent , $ child )))
650
630
;
651
-
652
631
$ kernel ->boot ();
653
632
654
633
$ map = $ kernel ->getBundleMap ();
@@ -793,17 +772,34 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
793
772
*/
794
773
protected function getKernel (array $ methods = array (), array $ bundles = array ())
795
774
{
775
+ $ methods [] = 'registerBundles ' ;
776
+
796
777
$ kernel = $ this
797
778
->getMockBuilder ('Symfony\Component\HttpKernel\Kernel ' )
798
779
->setMethods ($ methods )
799
780
->setConstructorArgs (array ('test ' , false ))
800
781
->getMockForAbstractClass ()
801
782
;
802
-
803
783
$ kernel ->expects ($ this ->any ())
804
784
->method ('registerBundles ' )
805
785
->will ($ this ->returnValue ($ bundles ))
806
786
;
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 ' );
807
803
808
804
return $ kernel ;
809
805
}
0 commit comments