本文整理汇总了PHP中Symfony\Component\Console\Tester\ApplicationTester::getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ApplicationTester::getStatusCode方法的具体用法?PHP ApplicationTester::getStatusCode怎么用?PHP ApplicationTester::getStatusCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Tester\ApplicationTester
的用法示例。
在下文中一共展示了ApplicationTester::getStatusCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExecute
public function testExecute()
{
$application = new Stratum();
$application->setAutoExit(false);
$tester = new ApplicationTester($application);
$tester->run(['config file' => 'test/MySql/etc/stratum.cfg']);
$this->assertSame(0, $tester->getStatusCode(), $tester->getDisplay());
}
示例2: testExistingHubApplication
/**
* Test Successful doRun.
*/
function testExistingHubApplication()
{
// Create a Mock Process Object.
$process = $this->getMockBuilder('Symfony\\Component\\Process\\Process')->disableOriginalConstructor()->getMock();
// Make sure the isSuccessful method return FALSE so flo throws an exception.
$process->method('isSuccessful')->willReturn(TRUE);
$app = new Console\Application();
// Set autoExit to false when testing & do not let it catch exceptions.
$app->setAutoExit(FALSE);
// Overwrite Symfony\Component\Process\Process with our mock Process.
$app->setProcess($process);
// Run a command and wait for the exception.
$appTester = new ApplicationTester($app);
$appTester->run(array('command' => 'help'));
$this->assertEquals(0, $appTester->getStatusCode());
}
示例3: testRunWithErrorFailingStatusCode
public function testRunWithErrorFailingStatusCode()
{
$application = new Application();
$application->setDispatcher($this->getDispatcher());
$application->setAutoExit(false);
$application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) {
$output->write('dus.');
throw new \Error('duserr');
});
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'dus'));
$this->assertSame(1, $tester->getStatusCode(), 'Status code should be 1');
}
示例4: testRunAsRoot
public function testRunAsRoot()
{
$stub = $this->getMock('SugarCli\\Console\\Application', array('isRunByRoot'), array('test', 'test'));
$stub->method('isRunByRoot')->willReturn(true);
$stub->setAutoExit(false);
$stub->add(new TestCommand());
$selfupdate_cmd = new TestCommand();
$selfupdate_cmd->setName('list');
$stub->add($selfupdate_cmd);
$tester = new ApplicationTester($stub);
$tester->run(array('command' => 'test:command'));
$this->assertEquals(6, $tester->getStatusCode());
$this->assertEquals('You are not allowed to run this command as root.' . PHP_EOL, $tester->getDisplay());
$tester = new ApplicationTester($stub);
$tester->run(array('command' => 'list'));
$this->assertEquals(0, $tester->getStatusCode());
$this->assertEquals(PHP_EOL, $tester->getDisplay());
}
示例5: getExitCode
/**
* @return int 0 success otherwise fail
*/
public function getExitCode()
{
return $this->tester->getStatusCode() !== null ? $this->tester->getStatusCode() : 1;
}