[Framework][router commands] fixed failing test.

This commit is contained in:
Abdellatif Ait boudad 2015-05-22 19:35:43 +00:00
parent dd744c9f53
commit 39cb6616a2
2 changed files with 22 additions and 14 deletions

View File

@ -56,7 +56,7 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
$command->setContainer($this->getContainer()); $command->setContainer($this->getContainer());
$application->add($command); $application->add($command);
return new CommandTester($application->find('router:debug')); return new CommandTester($application->find('debug:router'));
} }
private function getContainer() private function getContainer()
@ -65,11 +65,15 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
$routeCollection->add('foo', new Route('foo')); $routeCollection->add('foo', new Route('foo'));
$router = $this->getMock('Symfony\Component\Routing\RouterInterface'); $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
$router $router
->expects($this->atLeastOnce()) ->expects($this->any())
->method('getRouteCollection') ->method('getRouteCollection')
->will($this->returnValue($routeCollection)) ->will($this->returnValue($routeCollection))
; ;
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader')
->disableOriginalConstructor()
->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container $container
->expects($this->once()) ->expects($this->once())
@ -77,12 +81,13 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
->with('router') ->with('router')
->will($this->returnValue(true)) ->will($this->returnValue(true))
; ;
$container $container
->expects($this->atLeastOnce())
->method('get') ->method('get')
->with('router') ->will($this->returnValueMap(array(
->will($this->returnValue($router)) array('router', 1, $router),
; array('controller_name_converter', 1, $loader),
)));
return $container; return $container;
} }

View File

@ -74,19 +74,22 @@ class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($requestContext)) ->will($this->returnValue($requestContext))
; ;
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader')
->disableOriginalConstructor()
->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container $container
->expects($this->once()) ->expects($this->once())
->method('has') ->method('has')
->with('router') ->with('router')
->will($this->returnValue(true)) ->will($this->returnValue(true));
; $container->method('get')
$container ->will($this->returnValueMap(array(
->expects($this->atLeastOnce()) array('router', 1, $router),
->method('get') array('controller_name_converter', 1, $loader),
->with('router')
->will($this->returnValue($router)) )));
;
return $container; return $container;
} }