Exemple #1
0
 /**
  * Sets the current menu.
  * 
  * Sets the current menu.
  * 
  * @param string $newMenu The menu to change to. Can be specified with API
  *     or CLI syntax and can be either absolute or relative. If relative,
  *     it's relative to the current menu, which by default is the root.
  * 
  * @return $this The object itself. If an empty string is given for
  *     a new menu, no change is performed,
  *     but the ID cache is cleared anyway.
  * 
  * @see static::clearIdCache()
  */
 public function setMenu($newMenu)
 {
     $newMenu = (string) $newMenu;
     if ('' !== $newMenu) {
         $menuRequest = new Request('/menu');
         if ('/' === $newMenu[0]) {
             $this->menu = $menuRequest->setCommand($newMenu)->getCommand();
         } else {
             $this->menu = $menuRequest->setCommand('/' . str_replace('/', ' ', substr($this->menu, 1)) . ' ' . str_replace('/', ' ', $newMenu))->getCommand();
         }
     }
     $this->clearIdCache();
     return $this;
 }
 /**
  * @param string $command
  * @param string $expected
  * 
  * @dataProvider providerCommandTranslation
  * 
  * @return void
  */
 public function testCommandTranslation($command, $expected)
 {
     $request = new Request('/cancel');
     $request->setCommand($command);
     $this->assertEquals($expected, $request->getCommand(), "Command '{$command}' was not translated properly.");
 }