Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1949951

Browse filesBrowse files
author
Hugo Fonseca
committed
[Console] Tests for #18484 confirming status code when PHP Error is throw
1 parent ad5cb45 commit 1949951
Copy full SHA for 1949951

File tree

Expand file treeCollapse file tree

1 file changed

+34
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+34
-0
lines changed

‎src/Symfony/Component/Console/Tests/ApplicationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/ApplicationTest.php
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,40 @@ public function testRunDispatchesAllEventsWithException()
949949
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
950950
}
951951

952+
public function testRunDispatchesAllEventsWithError()
953+
{
954+
$application = new Application();
955+
$application->setDispatcher($this->getDispatcher());
956+
$application->setAutoExit(false);
957+
958+
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
959+
$output->write('dym.');
960+
961+
throw new \Error('dymerr');
962+
});
963+
964+
$tester = new ApplicationTester($application);
965+
$tester->run(array('command' => 'dym'));
966+
$this->assertContains('before.dym.caught.after.', $tester->getDisplay(), 'The PHP Error did not dispached events');
967+
}
968+
969+
public function testRunWithErrorFailingStatusCode()
970+
{
971+
$application = new Application();
972+
$application->setDispatcher($this->getDispatcher());
973+
$application->setAutoExit(false);
974+
975+
$application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) {
976+
$output->write('dus.');
977+
978+
throw new \Error('duserr');
979+
});
980+
981+
$tester = new ApplicationTester($application);
982+
$tester->run(array('command' => 'dus'));
983+
$this->assertSame(1, $tester->getStatusCode(), 'Status code should be 1');
984+
}
985+
952986
public function testRunWithDispatcherSkippingCommand()
953987
{
954988
$application = new Application();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.