1212namespace Symfony \Bundle \FrameworkBundle \Tests \Command ;
1313
1414use PHPUnit \Framework \TestCase ;
15- use Symfony \Component \Console \Application ;
15+ use Symfony \Bundle \ FrameworkBundle \Console \Application ;
1616use Symfony \Component \Console \Tester \CommandTester ;
1717use Symfony \Bundle \FrameworkBundle \Command \RouterMatchCommand ;
1818use Symfony \Bundle \FrameworkBundle \Command \RouterDebugCommand ;
19+ use Symfony \Component \HttpKernel \KernelInterface ;
1920use Symfony \Component \Routing \Route ;
2021use Symfony \Component \Routing \RouteCollection ;
2122use Symfony \Component \Routing \RequestContext ;
@@ -45,20 +46,14 @@ public function testWithNotMatchPath()
4546 */
4647 private function createCommandTester ()
4748 {
48- $ application = new Application ();
49-
50- $ command = new RouterMatchCommand ();
51- $ command ->setContainer ($ this ->getContainer ());
52- $ application ->add ($ command );
53-
54- $ command = new RouterDebugCommand ();
55- $ command ->setContainer ($ this ->getContainer ());
56- $ application ->add ($ command );
49+ $ application = new Application ($ this ->getKernel ());
50+ $ application ->add (new RouterMatchCommand ());
51+ $ application ->add (new RouterDebugCommand ());
5752
5853 return new CommandTester ($ application ->find ('router:match ' ));
5954 }
6055
61- private function getContainer ()
56+ private function getKernel ()
6257 {
6358 $ routeCollection = new RouteCollection ();
6459 $ routeCollection ->add ('foo ' , new Route ('foo ' ));
@@ -81,16 +76,27 @@ private function getContainer()
8176
8277 $ container = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ContainerInterface ' )->getMock ();
8378 $ container
84- ->expects ($ this ->once ())
79+ ->expects ($ this ->atLeastOnce ())
8580 ->method ('has ' )
8681 ->with ('router ' )
8782 ->will ($ this ->returnValue (true ));
88- $ container ->method ('get ' )
89- ->will ($ this ->returnValueMap (array (
90- array ('router ' , 1 , $ router ),
91- array ('controller_name_converter ' , 1 , $ loader ),
92- )));
83+ $ container
84+ ->expects ($ this ->any ())
85+ ->method ('get ' )
86+ ->willReturn ($ router );
87+
88+ $ kernel = $ this ->getMockBuilder (KernelInterface::class)->getMock ();
89+ $ kernel
90+ ->expects ($ this ->any ())
91+ ->method ('getContainer ' )
92+ ->willReturn ($ container )
93+ ;
94+ $ kernel
95+ ->expects ($ this ->once ())
96+ ->method ('getBundles ' )
97+ ->willReturn (array ())
98+ ;
9399
94- return $ container ;
100+ return $ kernel ;
95101 }
96102}
0 commit comments