예제 #1
0
파일: RouteTest.php 프로젝트: quenti77/phq
 /**
  * Permet de tester le matching de l'url avec des regex plus
  * ou moins précise et à différent niveaux.
  */
 public function testMatchWithParse()
 {
     $url = 'news/{id}-{slug:[a-z0-9]+}';
     $controller = 'Admin\\NewsController@details';
     $route = new Route("/{$url}/", $controller);
     $this->assertEquals('news/1-test', $route->getParseUrl(['id' => 1, 'slug' => 'test']));
     $this->assertFalse($route->match('///'));
     $this->assertTrue($route->match('/news/toto-test'));
     $route->with('id', '[0-9]+');
     $this->assertFalse($route->match('/news/toto-test'));
     $this->assertTrue($route->match('/news/1-test'));
 }
예제 #2
0
 /**
  * @param string $url
  */
 public function setUrl($url)
 {
     $this->url = Route::trimUrl($url);
 }
예제 #3
0
 /**
  * Permet d'ajouter à une route plusieurs with
  *
  * @param Route $route
  * @param array $with
  */
 private function addWiths(Route $route, array $with)
 {
     foreach ($with as $id => $regex) {
         if (!($id === null || $regex === null)) {
             $route->with($id, $regex);
         }
     }
 }