Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Console] Add getters for Application::$autoExit and $catchExceptions
  • Loading branch information
VasekPurchart committed Jan 27, 2016
commit 4862ed39dc07611c0e07a5eb86030048c6a2e77e
20 changes: 20 additions & 0 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ public function getHelp()
return $this->getLongVersion();
}

/**
* Gets whether to catch exceptions or not during commands execution.
*
* @return bool Whether to catch exceptions or not during commands execution
*/
public function areExceptionsCaught()
{
return $this->catchExceptions;
}

/**
* Sets whether to catch exceptions or not during commands execution.
*
Expand All @@ -266,6 +276,16 @@ public function setCatchExceptions($boolean)
$this->catchExceptions = (bool) $boolean;
}

/**
* Gets whether to automatically exit after a command execution or not.
*
* @return bool Whether to automatically exit after a command execution or not
*/
public function isAutoExitEnabled()
{
return $this->autoExit;
}

/**
* Sets whether to automatically exit after a command execution or not.
*
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ public function testSetCatchExceptions()
$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');

Expand All @@ -490,6 +491,15 @@ public function testSetCatchExceptions()
}
}

public function testAutoExitSetting()
{
$application = new Application();
$this->assertTrue($application->isAutoExitEnabled());

$application->setAutoExit(false);
$this->assertFalse($application->isAutoExitEnabled());
}

/**
* @group legacy
*/
Expand Down