File tree Expand file tree Collapse file tree 7 files changed +158
-0
lines changed
tests/end-to-end/regression Expand file tree Collapse file tree 7 files changed +158
-0
lines changed Original file line number Diff line number Diff line change 26
26
use function getcwd ;
27
27
use function implode ;
28
28
use function in_array ;
29
+ use function ini_get ;
29
30
use function ini_set ;
30
31
use function is_array ;
31
32
use function is_callable ;
83
84
use PHPUnit \Runner \BackedUpEnvironmentVariable ;
84
85
use PHPUnit \Runner \DeprecationCollector \Facade as DeprecationCollector ;
85
86
use PHPUnit \Runner \HookMethodCollection ;
87
+ use PHPUnit \Runner \ShutdownHandler ;
86
88
use PHPUnit \TestRunner \TestResult \PassedTests ;
87
89
use PHPUnit \TextUI \Configuration \Registry as ConfigurationRegistry ;
88
90
use PHPUnit \Util \Exporter ;
@@ -1297,6 +1299,10 @@ private function runTest(): mixed
1297
1299
1298
1300
$ capture = tmpfile ();
1299
1301
assert ($ capture !== false );
1302
+
1303
+ if (ini_get ('display_errors ' ) === '0 ' ) {
1304
+ ShutdownHandler::setMessage ('Fatal error: Premature end of PHP process. Use display_errors=On to see the error message. ' );
1305
+ }
1300
1306
$ errorLogPrevious = ini_set ('error_log ' , stream_get_meta_data ($ capture )['uri ' ]);
1301
1307
1302
1308
try {
@@ -1331,6 +1337,7 @@ private function runTest(): mixed
1331
1337
1332
1338
return null ;
1333
1339
} finally {
1340
+ ShutdownHandler::resetMessage ();
1334
1341
fclose ($ capture );
1335
1342
1336
1343
ini_set ('error_log ' , $ errorLogPrevious );
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+ /*
3
+ * This file is part of PHPUnit.
4
+ *
5
+ * (c) Sebastian Bergmann <[email protected] >
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+ namespace PHPUnit \Runner ;
11
+
12
+ use function register_shutdown_function ;
13
+
14
+ /**
15
+ * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
16
+ *
17
+ * @internal This class is not covered by the backward compatibility promise for PHPUnit
18
+ */
19
+ final class ShutdownHandler
20
+ {
21
+ private static bool $ registered = false ;
22
+ private static string $ message = '' ;
23
+
24
+ public static function setMessage (string $ message ): void
25
+ {
26
+ self ::register ();
27
+
28
+ self ::$ message = $ message ;
29
+ }
30
+
31
+ public static function resetMessage (): void
32
+ {
33
+ self ::$ message = '' ;
34
+ }
35
+
36
+ private static function register (): void
37
+ {
38
+ if (self ::$ registered ) {
39
+ return ;
40
+ }
41
+
42
+ register_shutdown_function (static function (): void
43
+ {
44
+ print self ::$ message ;
45
+ });
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ https://github.com/sebastianbergmann/phpunit/issues/6294
3
+ --INI--
4
+ display_errors=0
5
+ --FILE--
6
+ <?php declare (strict_types=1 );
7
+ $ _SERVER ['argv ' ][] = '--do-not-cache-result ' ;
8
+ $ _SERVER ['argv ' ][] = '--no-configuration ' ;
9
+ $ _SERVER ['argv ' ][] = __DIR__ . '/6294/IssueTest6294.php ' ;
10
+
11
+ require_once __DIR__ . '/../../bootstrap.php ' ;
12
+ (new PHPUnit \TextUI \Application )->run ($ _SERVER ['argv ' ]);
13
+ --EXPECTF --
14
+ PHPUnit %s by Sebastian Bergmann and contributors.
15
+
16
+ Runtime: %s
17
+
18
+ Fatal error: Premature end of PHP process. Use display_errors=On to see the error message.
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ https://github.com/sebastianbergmann/phpunit/issues/6294
3
+ --INI--
4
+ display_errors=1
5
+ --FILE--
6
+ <?php declare (strict_types=1 );
7
+ $ _SERVER ['argv ' ][] = '--do-not-cache-result ' ;
8
+ $ _SERVER ['argv ' ][] = '--no-configuration ' ;
9
+ $ _SERVER ['argv ' ][] = __DIR__ . '/6294/IssueTest6294.php ' ;
10
+
11
+ require_once __DIR__ . '/../../bootstrap.php ' ;
12
+ (new PHPUnit \TextUI \Application )->run ($ _SERVER ['argv ' ]);
13
+ --EXPECTF --
14
+ PHPUnit %s by Sebastian Bergmann and contributors.
15
+
16
+ Runtime: %s
17
+
18
+
19
+ Fatal error: Access level to PHPUnit\TestFixture \B::someFunction() must be public (as in class PHPUnit \TestFixture \A) in %sB.php on line %i%A
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+ /*
3
+ * This file is part of PHPUnit.
4
+ *
5
+ * (c) Sebastian Bergmann <[email protected] >
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+ namespace PHPUnit \TestFixture ;
11
+
12
+ use const PHP_EOL ;
13
+
14
+ class A
15
+ {
16
+ public function someFunction (): void
17
+ {
18
+ print 'A::someFunction ' . PHP_EOL ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+ /*
3
+ * This file is part of PHPUnit.
4
+ *
5
+ * (c) Sebastian Bergmann <[email protected] >
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+ namespace PHPUnit \TestFixture ;
11
+
12
+ use const PHP_EOL ;
13
+
14
+ class B extends A
15
+ {
16
+ // incorrect access level
17
+ protected function someFunction (): void
18
+ {
19
+ parent ::someFunction ();
20
+
21
+ print 'B::someFunction ' . PHP_EOL ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+ /*
3
+ * This file is part of PHPUnit.
4
+ *
5
+ * (c) Sebastian Bergmann <[email protected] >
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+ namespace PHPUnit \TestFixture ;
11
+
12
+ use PHPUnit \Framework \TestCase ;
13
+
14
+ final class IssueTest6294 extends TestCase
15
+ {
16
+ public function testOne (): void
17
+ {
18
+ require_once 'A.php ' ;
19
+
20
+ require_once 'B.php ' ;
21
+
22
+ $ this ->assertSame (1 , 1 );
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments