Пример #1
0
 /**
  * @test
  */
 public function booleanOptionsCanHaveOnlyCertainValuesIfTheValueIsAssignedWithoutEqualSign()
 {
     $methodParameters = array('b1' => array('optional' => TRUE, 'type' => 'boolean'), 'b2' => array('optional' => TRUE, 'type' => 'boolean'), 'b3' => array('optional' => TRUE, 'type' => 'boolean'), 'b4' => array('optional' => TRUE, 'type' => 'boolean'), 'b5' => array('optional' => TRUE, 'type' => 'boolean'), 'b6' => array('optional' => TRUE, 'type' => 'boolean'));
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Acme\\Test\\Command\\DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
     $expectedArguments = array('b1' => TRUE, 'b2' => TRUE, 'b3' => TRUE, 'b4' => FALSE, 'b5' => FALSE, 'b6' => FALSE);
     $request = $this->requestBuilder->build('acme.test:default:list --b2 y --b1 1 --b3 true --b4 false --b5 n --b6 0');
     $this->assertEquals($expectedArguments, $request->getArguments());
 }
Пример #2
0
 /**
  * Run the interactive Shell
  *
  * The shell command runs FLOW3's interactive shell. This shell allows for
  * entering commands like through the regular command line interface but
  * additionally supports autocompletion and a user-based command history.
  *
  * @return void
  */
 public function shellCommand()
 {
     if (!function_exists('readline_read_history')) {
         $this->outputLine('Interactive Shell is not available on this system!');
         $this->quit(1);
     }
     $subProcess = FALSE;
     $pipes = array();
     $historyPathAndFilename = getenv('HOME') . '/.flow3_' . md5(FLOW3_PATH_ROOT);
     readline_read_history($historyPathAndFilename);
     readline_completion_function(array($this, 'autocomplete'));
     echo "FLOW3 Interactive Shell\n\n";
     while (true) {
         $commandLine = readline('FLOW3 > ');
         if ($commandLine == '') {
             echo "\n";
             break;
         }
         readline_add_history($commandLine);
         readline_write_history($historyPathAndFilename);
         $request = $this->requestBuilder->build($commandLine);
         $response = new \TYPO3\FLOW3\Cli\Response();
         $command = $request->getCommand();
         if ($request === FALSE || $command->getCommandIdentifier() === FALSE) {
             echo "Bad command\n";
             continue;
         }
         if ($this->bootstrap->isCompiletimeCommand($command->getCommandIdentifier())) {
             $this->dispatcher->dispatch($request, $response);
             $response->send();
             if (is_resource($subProcess)) {
                 $this->quitSubProcess($subProcess, $pipes);
             }
         } else {
             if (is_resource($subProcess)) {
                 $subProcessStatus = proc_get_status($subProcess);
                 if ($subProcessStatus['running'] === FALSE) {
                     proc_close($subProcess);
                 }
             }
             if (!is_resource($subProcess)) {
                 list($subProcess, $pipes) = $this->launchSubProcess();
                 if ($subProcess === FALSE || !is_array($pipes)) {
                     echo "Failed launching the shell sub process for executing the runtime command.\n";
                     continue;
                 }
                 $this->echoSubProcessResponse($pipes);
             }
             fwrite($pipes[0], "{$commandLine}\n");
             fflush($pipes[0]);
             $this->echoSubProcessResponse($pipes);
             if ($command->isFlushingCaches()) {
                 $this->quitSubProcess($subProcess, $pipes);
             }
         }
     }
     if (is_resource($subProcess)) {
         $this->quitSubProcess($subProcess, $pipes);
     }
     echo "Bye!\n";
 }