Skip to content

Commit 0b15820

Browse files
Merge branch '12.3'
2 parents d00cfcd + 27e3b9c commit 0b15820

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

src/Runner/Phpt/TestCase.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use function preg_replace;
2828
use function preg_split;
2929
use function realpath;
30+
use function sprintf;
3031
use function str_contains;
3132
use function str_starts_with;
3233
use function strncasecmp;
@@ -349,6 +350,24 @@ private function shouldTestBeSkipped(array $sections, array $settings): bool
349350
$output = $this->runCodeInLocalSandbox($skipIfCode);
350351
}
351352

353+
if (str_contains($output, 'Parse error:')) {
354+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
355+
sprintf(
356+
'SKIPIF section triggered a parse error: %s',
357+
$output,
358+
),
359+
);
360+
}
361+
362+
if (str_contains($output, 'Fatal error:')) {
363+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
364+
sprintf(
365+
'SKIPIF section triggered a fatal error: %s',
366+
$output,
367+
),
368+
);
369+
}
370+
352371
if (strncasecmp('skip', ltrim($output), 4) === 0) {
353372
$message = '';
354373

tests/_files/skip-if-requires-code-coverage-driver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
if (!extension_loaded('xdebug')) {
2626
print 'skip: This test requires a code coverage driver';
27+
28+
return;
2729
}
2830

2931
if (version_compare(phpversion('xdebug'), '3.1', '>=') && in_array('coverage', xdebug_info('mode'), true)) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6311
3+
--SKIPIF--
4+
<?php declare(strict_types=1);
5+
require __DIR__ . '/some/non/existing/file.php';
6+
7+
--FILE--
8+
<?php declare(strict_types=1);
9+
10+
echo "hello world\n";
11+
--EXPECT--
12+
hello world
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/5991
3+
--SKIPIF--
4+
<?php
5+
if (rand(0,1)) // intentional PHP Parse error (missing opening curly brace)
6+
}
7+
--FILE--
8+
<?php declare(strict_types=1);
9+
echo 'hello world';
10+
--EXPECTF--
11+
hello world

tests/end-to-end/regression/5991.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/5991
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../_files/phpt-skipif-parse-error.phpt';
8+
9+
require_once __DIR__ . '/../../bootstrap.php';
10+
11+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
12+
--EXPECTF--
13+
PHPUnit %s by Sebastian Bergmann and contributors.
14+
15+
Runtime: %s
16+
17+
. 1 / 1 (100%)
18+
19+
Time: %s, Memory: %s
20+
21+
There was 1 PHPUnit test runner warning:
22+
23+
1) SKIPIF section triggered a parse error:
24+
Parse error: Unmatched '}' in Standard input code on line 3
25+
26+
27+
OK, but there were issues!
28+
Tests: 1, Assertions: 1, PHPUnit Warnings: 1.

tests/end-to-end/regression/6311.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6311
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../_files/phpt-skipif-invalid-require.phpt';
8+
9+
require_once __DIR__ . '/../../bootstrap.php';
10+
11+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
12+
--EXPECTF--
13+
PHPUnit %s by Sebastian Bergmann and contributors.
14+
15+
Runtime: %s
16+
17+
. 1 / 1 (100%)
18+
19+
Time: %s, Memory: %s
20+
21+
There was 1 PHPUnit test runner warning:
22+
23+
1) SKIPIF section triggered a fatal error:
24+
Warning: require(%afile.php): Failed to open stream: No such file or directory in Standard input code on line %d
25+
26+
Fatal error: Uncaught Error: Failed opening required%a
27+
%A

0 commit comments

Comments
 (0)