本文整理匯總了PHP中Symfony\Component\Console\Tester\CommandTester::getOutput方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommandTester::getOutput方法的具體用法?PHP CommandTester::getOutput怎麽用?PHP CommandTester::getOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Tester\CommandTester
的用法示例。
在下文中一共展示了CommandTester::getOutput方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFormattedOutput
public function testFormattedOutput()
{
$today = new \DateTimeImmutable();
// Show 1 has an upcoming episode.
for ($i = 1; $i <= 3; $i++) {
$serie = $this->getMockBuilder('Moinax\\TvDb\\Serie')->disableOriginalConstructor()->getMock();
$serie->id = 1;
$serie->name = "Serie {$i}";
$series[] = $serie;
}
$show_1 = [$this->getEpisode('S1E1', $today->modify("-7 days")), $this->getEpisode('S1E2', $today->modify('+7 days'))];
// Show 2 only has episodes in the past.
$show_2 = [$this->getEpisode('S2E1', $today->modify("-21 days")), $this->getEpisode('S2E2', $today->modify('-14 days'))];
// Show 3 has an episode coming out today.
$show_3 = [$this->getEpisode('S3E1', $today->modify("-7 days")), $this->getEpisode('S3E2', $today)];
$episodes = [['episodes' => $show_1], ['episodes' => $show_2], ['episodes' => $show_3]];
$shows = ['show1' => 'imdb1', 'show2' => 'imdb2', 'show3' => 'imdb3'];
$application = new Application();
$application->add($this->getCommand($series, $episodes, $shows));
$command = $application->find('status');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()], ['decorated' => TRUE]);
// $this->assertEquals('', $commandTester->getDisplay());
// $this->assertTrue(stripos($commandTester->getDisplay(), 'red') !== FALSE);
$a = $commandTester->getDisplay();
$b = $commandTester->getOutput();
}
示例2: setUp
public function setUp()
{
parent::setUp();
$this->application = new Application();
$this->application->add(new \DaemonCommandStub($this->commandName));
$this->command = $this->application->find($this->commandName);
$this->tester = new CommandTester($this->command);
$this->command->setOutputCallback(function () {
return $this->tester->getOutput();
});
}
示例3: testDiffReportingDecorated
/**
* @param string $expected
* @param string $format
* @param bool $isDecorated
*
* @dataProvider provideDiffReporting
*/
public function testDiffReportingDecorated($expected, $format, $isDecorated)
{
$command = new FixCommand();
$commandTester = new CommandTester($command);
$commandTester->execute(array('path' => array(__DIR__ . '/Fixtures/FixCommand/TextDiffTestInput.php'), '--diff' => true, '--dry-run' => true, '--format' => $format, '--rules' => 'concat_without_spaces', '--using-cache' => 'no'), array('decorated' => $isDecorated, 'verbosity' => OutputInterface::VERBOSITY_NORMAL));
if ($isDecorated !== $commandTester->getOutput()->isDecorated()) {
$this->markTestSkipped(sprintf('Output should %sbe decorated.', $isDecorated ? '' : 'not '));
}
if ($isDecorated !== $commandTester->getOutput()->getFormatter()->isDecorated()) {
$this->markTestSkipped(sprintf('Formatter should %sbe decorated.', $isDecorated ? '' : 'not '));
}
$this->assertStringMatchesFormat($expected, $commandTester->getDisplay(false));
}
示例4: getOutput
/**
* Returns the output for the tester.
*
* @param CommandTester $tester The tester.
*
* @return string The output.
*/
protected function getOutput(CommandTester $tester)
{
/** @var $output StreamOutput */
$output = $tester->getOutput();
$stream = $output->getStream();
$string = '';
rewind($stream);
while (false === feof($stream)) {
$string .= fgets($stream);
}
$string = preg_replace(array('/\\x1b(\\[|\\(|\\))[;?0-9]*[0-9A-Za-z]/', '/[\\x03|\\x1a]/'), array('', '', ''), $string);
return str_replace(PHP_EOL, "\n", $string);
}
示例5: testQuietStatus
public function testQuietStatus()
{
$cmd = $this->app->find('metadata:status');
$tester = new CommandTester($cmd);
$ret = $tester->execute(array('command' => $cmd->getName(), '--path' => __DIR__ . '/metadata/fake_sugar', '--metadata-file' => $this->getYamlFilename(MetadataTestCase::METADATA_NEW), '--quiet' => null));
$this->assertEquals(2, $ret);
// Test empty write*
$func_names = array('writeAdd', 'writeDel', 'writeUpdate');
$output = $tester->getOutput();
$reflex = new \ReflectionClass($cmd);
foreach ($func_names as $func_name) {
$method = $reflex->getMethod($func_name);
$method->setAccessible(true);
$this->assertNull($method->invoke($cmd, $output, array()));
}
}
示例6: shouldWriteCommitAndPushInfoWithVerbosityVerbose
/**
* @test
*/
public function shouldWriteCommitAndPushInfoWithVerbosityVerbose()
{
$gitDriver = $this->getMockBuilder('AOE\\Tagging\\Vcs\\Driver\\GitDriver')->disableOriginalConstructor()->setMethods(array('getLatestTag', 'tag', 'hasChangesSinceTag', 'commit'))->getMock();
$gitDriver->expects($this->once())->method('hasChangesSinceTag')->will($this->returnValue(true));
$gitDriver->expects($this->once())->method('getLatestTag')->will($this->returnValue('2.7.3'));
$gitDriver->expects($this->once())->method('commit')->with(array('myfile.ext'), '/home/foo/bar', 'my message for commit');
$gitCommand = $this->getMockBuilder('AOE\\Tagging\\Command\\GitCommand')->setMethods(array('getDriver'))->getMock();
$gitCommand->expects($this->once())->method('getDriver')->will($this->returnValue($gitDriver));
/** @var GitCommand $gitCommand */
$application = new Application();
$application->add($gitCommand);
$command = $application->find('git');
$commandTester = new CommandTester($command);
$test = $commandTester->getOutput();
$commandTester->execute(array('command' => $command->getName(), 'url' => 'git@git.test.test/foo/bar', 'path' => '/home/foo/bar', '--commit-and-push' => array('myfile.ext'), '--message' => 'my message for commit'), ['verbosity' => 2]);
}
示例7: testExecute
/**
* @covers ::configure
* @covers ::execute
*/
public function testExecute()
{
$mock = $this->getMockBuilder('MaartenStaa\\PHPTA\\CLI\\Command')->setMethods(array('getConfiguration', 'bootstrap', 'resolveTargets', 'createProject'))->getMock();
$config = new Configuration();
$mock->expects($this->once())->method('getConfiguration')->will($this->returnValue($config));
$mock->expects($this->once())->method('bootstrap')->with($config);
$mock->expects($this->once())->method('resolveTargets')->with($config)->will($this->returnValue(array('foo')));
$project = $this->getMockBuilder('MaartenStaa\\PHPTA\\Processors\\Project')->setMethods(array('process'))->setConstructorArgs(array(array(), array(), false))->getMock();
$mock->expects($this->once())->method('createProject')->with($config)->will($this->returnValue($project));
$project->expects($this->once())->method('process')->with($this->equalTo(array('foo')), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\StreamOutput'));
$application = new Application('PHPTA', 'v1.2.34');
$application->add($mock);
$command = $application->find('phpta');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName()));
$this->assertEquals('PHPTA version v1.2.34 by Maarten Staa.' . PHP_EOL . PHP_EOL, $this->getDisplay($commandTester->getOutput()));
}