Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function getPathMatcherForRoute(Route $route)
 {
     $pathMatcher = preg_replace('#\\[:(.+?)\\]#i', '(?P<$1>.+?)/?', $route->getPath());
     return sprintf('#^%s$#i', $pathMatcher);
 }
 /**
  * @test
  * @expectedException \ConfigurationException
  */
 public function throwsAnExceptionIfTargetIsCallableAndAddedRouteHasNoNameDefined()
 {
     $this->router->addRoute(Route::get('/something')->to(function () {
         // do nothing
     }));
 }
Example #3
0
 /**
  * @test
  */
 public function addingMatcherIsImmutable()
 {
     $matcher = $this->getMock(Matcher::class);
     $route = Route::create('/user/[:id]');
     $route2 = $route->ifMatches('id', $matcher);
     $this->assertInstanceOf(Route::class, $route2);
     $this->assertNotEquals($route->getMatchers(), $route2->getMatchers());
 }
Example #4
0
 /**
  * Returns the identifier string for given route.
  *
  * @param Route $route
  * @return string
  */
 protected function getRouteIdentifier(Route $route) : string
 {
     return empty($route->getName()) ? $route->getTarget() : $route->getName();
 }