diff --git a/tests/src/PHPRouterTest/RouteTest.php b/tests/src/PHPRouterTest/RouteTest.php index a8e7b2b..1161d7e 100644 --- a/tests/src/PHPRouterTest/RouteTest.php +++ b/tests/src/PHPRouterTest/RouteTest.php @@ -18,10 +18,14 @@ namespace PHPRouterTest\Test; use PHPRouter\Route; +use PHPRouter\Test\SomeController; use PHPUnit_Framework_TestCase; class RouteTest extends PHPUnit_Framework_TestCase { + /** + * @var Route + */ private $routeWithParameters; protected function setUp() @@ -93,4 +97,24 @@ public function testGetAction() { $this->assertEquals('page', $this->routeWithParameters->getAction()); } + + public function testShouldGetInstanceFromContainerIfContainerIsProvided() + { + /* @var $container \PHPUnit_Framework_MockObject_MockObject|\Interop\Container\ContainerInterface */ + $container = $this->getMock('Interop\Container\ContainerInterface'); + + $container->expects(self::once()) + ->method('has') + ->with('PHPRouter\Test\SomeController') + ->willReturn(true); + + $container->expects(self::once()) + ->method('get') + ->with('PHPRouter\Test\SomeController') + ->willReturn(new SomeController()); + + $this->routeWithParameters->setContainer($container); + + $this->routeWithParameters->dispatch(); + } }