當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ApplicationTester::getStatusCode方法代碼示例

本文整理匯總了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());
 }
開發者ID:setbased,項目名稱:php-stratum,代碼行數:8,代碼來源:StratumApplicationTest.php

示例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());
 }
開發者ID:rabellamy,項目名稱:flo,代碼行數:19,代碼來源:ApplicationTest.php

示例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');
 }
開發者ID:heximcz,項目名稱:bind-manager,代碼行數:13,代碼來源:ApplicationTest.php

示例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());
 }
開發者ID:inetprocess,項目名稱:sugarcli,代碼行數:18,代碼來源:ApplicationTest.php

示例5: getExitCode

 /**
  * @return int 0 success otherwise fail
  */
 public function getExitCode()
 {
     return $this->tester->getStatusCode() !== null ? $this->tester->getStatusCode() : 1;
 }
開發者ID:rezzza,項目名稱:tk1-contexts,代碼行數:7,代碼來源:CommandContext.php


注:本文中的Symfony\Component\Console\Tester\ApplicationTester::getStatusCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。