function it_should_read_user_input(OutputInterface $output, Application $application) { $application->run(Argument::that(function (StringInput $value) { return $value->getFirstArgument() === 'all'; }), $output)->shouldBeCalled()->willReturn('retval'); $application->getName()->shouldNotBeCalled(); $this->readline(false); // show prompt when true $application->getName()->shouldBeCalled(); $this->readline(true); }
/** * @param string $input * @param array $options * * @return integer */ public function run($input, array $options = array()) { if (isset($options['interactive']) && $options['interactive']) { $this->input = new InteractiveStringInput($input); } else { $this->input = new StringInput($input); $this->input->setInteractive(false); } $this->output = new StreamOutput(fopen('php://memory', 'w', false)); if (isset($options['decorated'])) { $this->output->setDecorated($options['decorated']); } if (isset($options['verbosity'])) { $this->output->setVerbosity($options['verbosity']); } $inputStream = $this->getInputStream(); rewind($inputStream); $this->getDialogHelper()->setInputStream($inputStream); $this->statusCode = $this->application->run($this->input, $this->output); return $this->statusCode; }
/** * @throws \Exception * @group phpspec */ public function testShouldPassPhpSpecTest() { try { $app = new Application('phpguard-listen-spec'); $app->setAutoExit(false); $app->setCatchExceptions(true); $input = new StringInput('run --ansi'); $return = $app->run($input); $this->assertEquals(0, $return, 'PhpGuard Spec Testing is not passed.'); } catch (\Exception $e) { throw $e; } }