/** @test */ public function itShouldDispatchRoute() { $route = $this->mockRoute(); $route->method('getMethods')->willReturn(['GET']); $route->method('getSchemes')->willReturn(['http']); $router = new Router($routes = new Routes(['foo' => $route]), null, $dispatcher = $this->mockDispatcher(), null, $url = $this->mockUrl()); $url->expects($this->once())->method('generate')->willReturnCallback(function ($name) { if ('foo' !== $name) { $this->fail(); } return '/foo/bar'; }); $dispatcher->expects($this->once())->method('dispatch')->willReturnCallback(function ($context) use($router, $route) { if ('/foo/bar' !== $context->getPath()) { $this->fail(); } /* * @todo iwyg <*****@*****.**>; Fr 22 Jan 20:42:04 2016 --> * create a explicit testcase */ $this->assertSame('foo', $router->getFirstRouteName()); $this->assertSame('foo', $router->getCurrentRouteName()); return 'ok'; }); $this->assertSame('ok', $router->route('foo')); }