Пример #1
0
 /**
  * Checks if the route collection is responsible for the requested route and collection.
  * @param string $routeName
  * @param string $collectionName
  * @param \Brickoo\Component\Routing\Route\RouteCollection $routeCollection
  * @return boolean
  */
 private function isCollectionResponsible($routeName, $collectionName, RouteCollection $routeCollection)
 {
     return (empty($collectionName) || $routeCollection->getName() == $collectionName) && $routeCollection->hasRoute($routeName);
 }
Пример #2
0
 /** {@inheritDoc} */
 public function matchesCollection(RouteCollection $routeCollection)
 {
     return !$routeCollection->hasPath() || strpos($this->matchingPath, $routeCollection->getPath()) === 0;
 }
Пример #3
0
 /** {@inheritDoc} */
 public function matchesCollection(RouteCollection $routeCollection)
 {
     return !$routeCollection->hasPath() || strpos($this->request->getUri()->getPath(), $routeCollection->getPath()) === 0;
 }
Пример #4
0
 /** @covers Brickoo\Component\Routing\Route\RouteCollection::getIterator */
 public function testGetIterator()
 {
     $route = $this->getRouteStub();
     $route->expects($this->any())->method("getName")->will($this->returnValue("test.route"));
     $routeCollection = new RouteCollection("name", "/path");
     $routeCollection->addRoutes([$route]);
     $iterator = $routeCollection->getIterator();
     $this->assertInstanceOf("Traversable", $iterator);
     $iterator->rewind();
     $this->assertSame($route, $iterator->current());
 }
Пример #5
0
 /**
  * @covers Brickoo\Component\Routing\Router::getRequestRoute
  * @covers Brickoo\Component\Routing\Router::getMatchingRoute
  * @covers Brickoo\Component\Routing\Router::getMatchingRequestRouteFromCollection
  */
 public function testGetRequestRoute()
 {
     $route = new GenericRoute("unit.test.route", "/test", "Controller");
     $routeCollector = new CallbackRouteCollector(function () use($route) {
         $routeCollection = new RouteCollection("unit-test-collection");
         $routeCollection->addRoutes([$route]);
         return [$routeCollection];
     });
     $router = new Router($routeCollector, new BasicRouteMatcher("/test", new RoutePathRegexGenerator()));
     $requestRoute = $router->getRequestRoute();
     $this->assertSame($route, $requestRoute->getRoute());
 }