Skip to content

Commit 7aa7b77

Browse files
Split test into separate tests for exit() with and without message
1 parent 2ebbbf2 commit 7aa7b77

File tree

4 files changed

+39
-28
lines changed

4 files changed

+39
-28
lines changed

tests/end-to-end/cli/shutdown-handler/WithExitTest.php renamed to tests/end-to-end/_files/WithExitTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ final class WithExitTest extends TestCase
1616
public function testWithMessage(): void
1717
{
1818
$this->assertTrue(true);
19-
$this->assertTrue(true);
2019

21-
exit('My Custom Exit Message');
20+
exit('message');
2221
}
2322

2423
public function testWithoutMessage(): void
2524
{
2625
$this->assertTrue(true);
27-
$this->assertTrue(true);
2826

2927
exit(1);
3028
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Shutdown Handler: exit(1)
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--filter';
8+
$_SERVER['argv'][] = 'testWithMessage';
9+
$_SERVER['argv'][] = __DIR__ . '/../_files/WithExitTest.php';
10+
11+
require __DIR__ . '/../../bootstrap.php';
12+
13+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
14+
--EXPECTF--
15+
PHPUnit %s by Sebastian Bergmann and contributors.
16+
17+
Runtime: %s
18+
19+
messageFatal error: Premature end of PHP process when running PHPUnit\TestFixture\WithExitTest::testWithMessage.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Shutdown Handler: exit('message')
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--filter';
8+
$_SERVER['argv'][] = 'testWithoutMessage';
9+
$_SERVER['argv'][] = __DIR__ . '/../_files/WithExitTest.php';
10+
11+
require __DIR__ . '/../../bootstrap.php';
12+
13+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
14+
--EXPECTF--
15+
PHPUnit %s by Sebastian Bergmann and contributors.
16+
17+
Runtime: %s
18+
19+
Fatal error: Premature end of PHP process when running PHPUnit\TestFixture\WithExitTest::testWithoutMessage.

tests/end-to-end/cli/shutdown-handler/test.phpt

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)