예제 #1
0
 /**
  * @param $isInArgs
  * @param Container $services
  * @return Router
  */
 private function provideRouter($isInArgs, Container $services)
 {
     $router = new Router(new RouteFinder($services));
     $router->addRoute(new Route(new RoutePattern($isInArgs ? ':all' : 'REQUEST_URI'), function () {
     }));
     $router->find(new Request([], [], [], [], [], ['REQUEST_URI' => 'REQUEST_URI']));
     return $router;
 }
 /**
  * @param Router $router
  * @param callable $controller
  */
 private function assertRouter(Router $router, callable $controller)
 {
     $routes = $router->getRoutes();
     $this->assertArrayHasKey(0, $routes);
     $this->assertEquals($controller, $routes[0]->getController());
     $controller = $routes[0]->getController();
     $this->assertInstanceOf('Puppy\\Controller\\AppController', $controller());
     $this->assertSame('GET', $routes[0]->getPattern()->getMethod());
     $this->assertSame('application/json', $routes[0]->getPattern()->getContentType());
 }
예제 #3
0
 /**
  *
  */
 public function testGetCurrentRoute()
 {
     $request = new RequestMock();
     $request->setRequestUri('uri');
     $route = new Route(new RoutePattern('uri'), function () {
     });
     $router = new Router(new RouteFinder(new Container()));
     $router->addRoute($route);
     $this->assertNull($router->getCurrentRoute());
     $router->find($request, new \ArrayObject());
     $this->assertSame($route, $router->getCurrentRoute());
 }