/** * @test * @dataProvider quotedValues */ public function quotedArgumentValuesAreCorrectlyParsedWhenPassingTheCommandAsString($quotedArgument, $expectedResult) { $methodParameters = ['requiredArgument1' => ['optional' => false, 'type' => 'string'], 'requiredArgument2' => ['optional' => false, 'type' => 'string']]; $this->mockCommandManager->expects($this->once())->method('getCommandMethodParameters')->with('Acme\\Test\\Command\\DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters)); $expectedArguments = ['requiredArgument1' => 'firstArgumentValue', 'requiredArgument2' => $expectedResult]; $request = $this->requestBuilder->build('acme.test:default:list firstArgumentValue ' . $quotedArgument); $this->assertEquals($expectedArguments, $request->getArguments()); }
/** * Run the interactive Shell * * The shell command runs Flow'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 = []; $historyPathAndFilename = getenv('HOME') . '/.flow_' . md5(FLOW_PATH_ROOT); readline_read_history($historyPathAndFilename); readline_completion_function([$this, 'autocomplete']); echo "Flow Interactive Shell\n\n"; while (true) { $commandLine = readline('Flow > '); if ($commandLine == '') { echo "\n"; break; } readline_add_history($commandLine); readline_write_history($historyPathAndFilename); $request = $this->requestBuilder->build($commandLine); $response = new 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"; }