Ejemplo n.º 1
0
 /**
  * Test du bloquage des méthodes
  */
 public function testLockMethods()
 {
     $routes = new Routes();
     // setIndex
     $catched = false;
     try {
         $routes->setIndex();
     } catch (BadMethodCallException $e) {
         $this->assertEquals('Impossible to call "setIndex"', $e->getMessage());
         $catched = true;
     }
     $this->assertTrue($catched);
     // setRoutes
     $catched = false;
     try {
         $routes->setRoutes();
     } catch (BadMethodCallException $e) {
         $this->assertEquals('Impossible to call "setRoutes"', $e->getMessage());
         $catched = true;
     }
     $this->assertTrue($catched);
 }
Ejemplo n.º 2
0
 /**
  * Ajoute plusieurs routes à la même méthode
  *
  * @param array $methods
  * @param string $path
  * @param string|callable $callable
  * @param array $with
  * @return Routes
  */
 public function match(array $methods, $path, $callable, array $with = [])
 {
     if (empty($methods)) {
         throw new InvalidArgumentException('No methods pass on this function');
     }
     $routes = new Routes();
     foreach ($methods as $method) {
         $route = $this->callMethod($method, $path, $callable);
         if ($route) {
             $this->addWiths($route, $with);
             $routes->add($route);
         }
     }
     return $routes;
 }