Example #1
0
 public function testShutdown()
 {
     ob_start();
     $test_print = "Test output.";
     print $test_print;
     $app = new Application('test', 'beta');
     $app->registerShutdownFunction();
     $app->setAutoExit(false);
     $tester = new ApplicationTester($app);
     $tester->run(array('--version' => null));
     $this->assertEquals('test version beta' . PHP_EOL, $tester->getDisplay());
     $this->assertEquals(0, $tester->getStatusCode());
     $reflection = new \ReflectionClass($app);
     $runOk = $reflection->getProperty('runOk');
     $runOk->setAccessible(true);
     $this->assertTrue($runOk->getValue($app));
     $runOk->setValue($app, false);
     Application::shutdownFunction($app);
     $this->assertContains('exit() or die() called before the end of the command.', $tester->getDisplay());
     $this->assertContains($test_print, $tester->getDisplay());
 }