This repository was archived by the owner on Dec 6, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1818namespace PHPRouterTest \Test ;
1919
2020use PHPRouter \Route ;
21+ use PHPRouter \Test \SomeController ;
2122use PHPUnit_Framework_TestCase ;
2223
2324class RouteTest extends PHPUnit_Framework_TestCase
2425{
26+ /**
27+ * @var Route
28+ */
2529 private $ routeWithParameters ;
2630
2731 protected function setUp ()
@@ -93,4 +97,24 @@ public function testGetAction()
9397 {
9498 self ::assertEquals ('page ' , $ this ->routeWithParameters ->getAction ());
9599 }
100+
101+ public function testShouldGetInstanceFromContainerIfContainerIsProvided ()
102+ {
103+ /* @var $container \PHPUnit_Framework_MockObject_MockObject|\Interop\Container\ContainerInterface */
104+ $ container = $ this ->getMock ('Interop\Container\ContainerInterface ' );
105+
106+ $ container ->expects (self ::once ())
107+ ->method ('has ' )
108+ ->with ('PHPRouter\Test\SomeController ' )
109+ ->willReturn (true );
110+
111+ $ container ->expects (self ::once ())
112+ ->method ('get ' )
113+ ->with ('PHPRouter\Test\SomeController ' )
114+ ->willReturn (new SomeController ());
115+
116+ $ this ->routeWithParameters ->setContainer ($ container );
117+
118+ $ this ->routeWithParameters ->dispatch ();
119+ }
96120}
You can’t perform that action at this time.
0 commit comments