本文整理匯總了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;
}