/** * @test * @dataProvider quotedValues */ public function quotedArgumentValuesAreCorrectlyParsedWhenPassingTheCommandAsString($quotedArgument, $expectedResult) { $methodParameters = array('requiredArgument1' => array('optional' => FALSE, 'type' => 'string'), 'requiredArgument2' => array('optional' => FALSE, 'type' => 'string')); $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Acme\\Test\\Command\\DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters)); $expectedArguments = array('requiredArgument1' => 'firstArgumentValue', 'requiredArgument2' => $expectedResult); $request = $this->requestBuilder->build('acme.test:default:list firstArgumentValue ' . $quotedArgument); $this->assertEquals($expectedArguments, $request->getArguments()); }
/** * @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()); }
/** * 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 = array(); $historyPathAndFilename = getenv('HOME') . '/.flow_' . md5(FLOW_PATH_ROOT); readline_read_history($historyPathAndFilename); readline_completion_function(array($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"; }