Ejemplo n.º 1
0
 public function testMatch()
 {
     $expectedResult = new MatchedRoute(new \stdClass(), 'index', []);
     $matchedRouter = $this->getMock('Emonkak\\Waf\\Routing\\RouterInterface');
     $matchedRouter->expects($this->once())->method('match')->willReturn($expectedResult);
     $nullRouter = $this->getMock('Emonkak\\Waf\\Routing\\RouterInterface');
     $nullRouter->expects($this->once())->method('match')->willReturn(null);
     $nerverCalledRouter = $this->getMock('Emonkak\\Waf\\Routing\\RouterInterface');
     $nerverCalledRouter->expects($this->never())->method('match');
     $router = new RouterCollection([$nullRouter, $matchedRouter, $nerverCalledRouter]);
     $request = new Request();
     $this->assertSame($expectedResult, $router->match($request));
     $router = new RouterCollection([]);
     $this->assertNull($router->match($request));
 }