Gets whether to catch exceptions or not during commands execution.
public areExceptionsCaught ( ) : boolean | ||
return | boolean | Whether to catch exceptions or not during commands execution |
public function testSetCatchExceptions() { $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=120'); $tester = new ApplicationTester($application); $application->setCatchExceptions(true); $this->assertTrue($application->areExceptionsCaught()); $tester->run(array('command' => 'foo'), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception1.txt', $tester->getErrorOutput(true), '->setCatchExceptions() sets the catch exception flag'); $this->assertSame('', $tester->getDisplay(true)); $application->setCatchExceptions(false); try { $tester->run(array('command' => 'foo'), array('decorated' => false)); $this->fail('->setCatchExceptions() sets the catch exception flag'); } catch (\Exception $e) { $this->assertInstanceOf('\\Exception', $e, '->setCatchExceptions() sets the catch exception flag'); $this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag'); } }