当前位置: 首页>>代码示例>>PHP>>正文


PHP ApplicationTester::getOutput方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Tester\ApplicationTester::getOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP ApplicationTester::getOutput方法的具体用法?PHP ApplicationTester::getOutput怎么用?PHP ApplicationTester::getOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Tester\ApplicationTester的用法示例。


在下文中一共展示了ApplicationTester::getOutput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRun

 /**
  * @dataProvider provider
  */
 public function testRun($command, $result)
 {
     $app = new \Phinx\Console\PhinxApplication('testing');
     $app->setAutoExit(false);
     // Set autoExit to false when testing
     $app->setCatchExceptions(false);
     $appTester = new ApplicationTester($app);
     $appTester->run(array('command' => $command));
     $stream = $appTester->getOutput()->getStream();
     rewind($stream);
     $this->assertRegExp($result, stream_get_contents($stream));
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:15,代码来源:PhinxApplicationTest.php

示例2: testRun

 public function testRun()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add($command = new \Foo1Command());
     $_SERVER['argv'] = array('cli.php', 'foo:bar1');
     ob_start();
     $application->run();
     ob_end_clean();
     $this->assertInstanceOf('Symfony\\Component\\Console\\Input\\ArgvInput', $command->input, '->run() creates an ArgvInput by default if none is given');
     $this->assertInstanceOf('Symfony\\Component\\Console\\Output\\ConsoleOutput', $command->output, '->run() creates a ConsoleOutput by default if none is given');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $this->ensureStaticCommandHelp($application);
     $tester = new ApplicationTester($application);
     $tester->run(array(), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed');
     $tester->run(array('--help' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed');
     $tester->run(array('-h' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed');
     $tester->run(array('command' => 'list', '--help' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed');
     $tester->run(array('command' => 'list', '-h' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed');
     $tester->run(array('--ansi' => true));
     $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed');
     $tester->run(array('--no-ansi' => true));
     $this->assertFalse($tester->getOutput()->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed');
     $tester->run(array('--version' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed');
     $tester->run(array('-V' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed');
     $tester->run(array('command' => 'list', '--quiet' => true));
     $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
     $tester->run(array('command' => 'list', '-q' => true));
     $this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
     $tester->run(array('command' => 'list', '--verbose' => true));
     $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');
     $tester->run(array('command' => 'list', '--verbose' => 1));
     $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose=1 is passed');
     $tester->run(array('command' => 'list', '--verbose' => 2));
     $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to very verbose if --verbose=2 is passed');
     $tester->run(array('command' => 'list', '--verbose' => 3));
     $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to debug if --verbose=3 is passed');
     $tester->run(array('command' => 'list', '--verbose' => 4));
     $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if unknown --verbose level is passed');
     $tester->run(array('command' => 'list', '-v' => true));
     $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed');
     $tester->run(array('command' => 'list', '-vv' => true));
     $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed');
     $tester->run(array('command' => 'list', '-vvv' => true));
     $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add(new \FooCommand());
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'foo:bar', '--no-interaction' => true), array('decorated' => false));
     $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed');
     $tester->run(array('command' => 'foo:bar', '-n' => true), array('decorated' => false));
     $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:65,代码来源:ApplicationTest.php

示例3: testRun

 public function testRun()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add($command = new \Foo1Command());
     $_SERVER['argv'] = array('cli.php', 'foo:bar1');
     ob_start();
     $application->run();
     ob_end_clean();
     $this->assertEquals('Symfony\\Component\\Console\\Input\\ArgvInput', get_class($command->input), '->run() creates an ArgvInput by default if none is given');
     $this->assertEquals('Symfony\\Component\\Console\\Output\\ConsoleOutput', get_class($command->output), '->run() creates a ConsoleOutput by default if none is given');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array());
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run1.txt', $this->normalize($tester->getDisplay()), '->run() runs the list command if no argument is passed');
     $tester->run(array('--help' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $this->normalize($tester->getDisplay()), '->run() runs the help command if --help is passed');
     $tester->run(array('-h' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $this->normalize($tester->getDisplay()), '->run() runs the help command if -h is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'list', '--help' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $this->normalize($tester->getDisplay()), '->run() displays the help if --help is passed');
     $tester->run(array('command' => 'list', '-h' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $this->normalize($tester->getDisplay()), '->run() displays the help if -h is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('--ansi' => true));
     $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed');
     $tester->run(array('-a' => true));
     $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if -a is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('--version' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $this->normalize($tester->getDisplay()), '->run() displays the program version if --version is passed');
     $tester->run(array('-V' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $this->normalize($tester->getDisplay()), '->run() displays the program version if -v is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'list', '--quiet' => true));
     $this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if --quiet is passed');
     $tester->run(array('command' => 'list', '-q' => true));
     $this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if -q is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'list', '--verbose' => true));
     $this->assertEquals(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose is --verbose is passed');
     $tester->run(array('command' => 'list', '-v' => true));
     $this->assertEquals(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose is -v is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add(new \FooCommand());
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'foo:bar', '--no-interaction' => true));
     $this->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if --no-interaction is passed');
     $tester->run(array('command' => 'foo:bar', '-n' => true));
     $this->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if -n is passed');
 }
开发者ID:spf13,项目名称:symfony,代码行数:72,代码来源:ApplicationTest.php


注:本文中的Symfony\Component\Console\Tester\ApplicationTester::getOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。