Beispiel #1
0
 /**
  * Permet de définir des groupes de routes pour ne pas
  * avoir à recopier certaines parties de la route
  *
  * @param string|array $options
  * @param callable $callback
  */
 public function group($options, callable $callback)
 {
     $groupOptions = ['prefix' => '', 'middlewares' => []];
     if (is_string($options)) {
         $groupOptions['prefix'] = $options;
     } else {
         $groupOptions = array_merge($groupOptions, $options);
     }
     $this->groups->add($groupOptions['prefix'], $groupOptions['middlewares']);
     $callback($this);
     $this->groups->remove();
 }
Beispiel #2
0
 /**
  * Permet de tester que les méthodes innaccessible le sont bien
  */
 public function testLockMethods()
 {
     $test = new RouteGroup();
     // getPile
     $catched = false;
     try {
         $test->getPile();
     } catch (BadMethodCallException $e) {
         $this->assertEquals('Impossible to call "getPile"', $e->getMessage());
         $catched = true;
     }
     $this->assertTrue($catched);
     // setPile
     $catched = false;
     try {
         $test->setPile();
     } catch (BadMethodCallException $e) {
         $this->assertEquals('Impossible to call "setPile"', $e->getMessage());
         $catched = true;
     }
     $this->assertTrue($catched);
     // setPrefix
     $catched = false;
     try {
         $test->setPrefix();
     } catch (BadMethodCallException $e) {
         $this->assertEquals('Impossible to call "setPrefix"', $e->getMessage());
         $catched = true;
     }
     $this->assertTrue($catched);
     // setMiddlewares
     $catched = false;
     try {
         $test->setMiddlewares();
     } catch (BadMethodCallException $e) {
         $this->assertEquals('Impossible to call "setMiddlewares"', $e->getMessage());
         $catched = true;
     }
     $this->assertTrue($catched);
 }