@@ -59,18 +59,50 @@ public function testGet()
5959 /**
6060 * @covers OpCacheGUI\Network\Router::__construct
6161 * @covers OpCacheGUI\Network\Router::run
62+ * @covers OpCacheGUI\Network\Router::getMainPage
6263 */
63- public function testRunNoMatch ()
64+ public function testRunNoMatchFirstMatchMain ()
6465 {
6566 $ requestMock = $ this ->getMock ('\\OpCacheGUI \\Network \\RequestData ' );
6667 $ requestMock ->method ('getVerb ' )->willReturn ('GET ' );
6768 $ requestMock ->method ('path ' )->willReturn ('somepath ' );
6869
70+ $ routeMock = $ this ->getMockBuilder ('\\OpCacheGUI \\Network \\Route ' )->disableOriginalConstructor ()->getMock ();
71+ $ routeMock ->method ('matchesRequest ' )->will ($ this ->onConsecutiveCalls (false , true ));
72+ $ routeMock ->method ('run ' )->willReturn ('main route ' );
73+
74+ $ factoryMock = $ this ->getMock ('\\OpCacheGUI \\Network \\RouteBuilder ' );
75+ $ factoryMock ->method ('build ' )->willReturn ($ routeMock );
76+
77+ $ router = new Router ($ requestMock , $ factoryMock );
78+ $ router ->get ('id ' , function () {});
79+
80+ $ this ->assertSame ('main route ' , $ router ->run ());
81+ }
82+
83+ /**
84+ * @covers OpCacheGUI\Network\Router::__construct
85+ * @covers OpCacheGUI\Network\Router::run
86+ * @covers OpCacheGUI\Network\Router::getMainPage
87+ */
88+ public function testRunNoMatchSecondMatchMain ()
89+ {
90+ $ requestMock = $ this ->getMock ('\\OpCacheGUI \\Network \\RequestData ' );
91+ $ requestMock ->method ('getVerb ' )->willReturn ('GET ' );
92+ $ requestMock ->method ('path ' )->willReturn ('somepath ' );
93+
94+ $ routeMock = $ this ->getMockBuilder ('\\OpCacheGUI \\Network \\Route ' )->disableOriginalConstructor ()->getMock ();
95+ $ routeMock ->method ('matchesRequest ' )->will ($ this ->onConsecutiveCalls (false , false , false , true ));
96+ $ routeMock ->method ('run ' )->willReturn ('main route ' );
97+
6998 $ factoryMock = $ this ->getMock ('\\OpCacheGUI \\Network \\RouteBuilder ' );
99+ $ factoryMock ->method ('build ' )->willReturn ($ routeMock );
70100
71101 $ router = new Router ($ requestMock , $ factoryMock );
102+ $ router ->get ('id ' , function () {});
103+ $ router ->post ('id ' , function () {});
72104
73- $ this ->assertSame ('No route matches ' , $ router ->run ());
105+ $ this ->assertSame ('main route ' , $ router ->run ());
74106 }
75107
76108 /**
0 commit comments