Skip to content

Commit 8eba5dc

Browse files
Merge branch '11.5'
2 parents f72a244 + 32d804b commit 8eba5dc

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/Runner/PHPT/PhptTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ private function shouldRunSkipIfInSubprocess(array $sections, string $skipIfCode
528528

529529
private function runCodeInLocalSandbox(string $code): string
530530
{
531-
$code = preg_replace('/^<\?(php)?/', '', $code);
531+
$code = preg_replace('/^<\?(?:php)?|\?>\s*+$/', '', $code);
532532
$code = preg_replace('/declare\S?\([^)]+\)\S?;/', '', $code);
533533

534534
// wrap in immediately invoked function to isolate local-side-effects of $code from our own process
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
PHPT skip condition which is terminated with a closing PHP tag
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
print "Nothing to see here, move along";
6+
--SKIPIF--
7+
<?php declare(strict_types=1);
8+
print "skip: something terrible happened\n";
9+
?>
10+
--EXPECT--
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
The right events are emitted in the right order for a skipped PHPT test
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--debug';
8+
$_SERVER['argv'][] = __DIR__ . '/../_files/phpt-skipif-closing-php-tag.phpt';
9+
10+
require __DIR__ . '/../../bootstrap.php';
11+
12+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
13+
--EXPECTF--
14+
PHPUnit Started (PHPUnit %s using %s)
15+
Test Runner Configured
16+
Event Facade Sealed
17+
Test Suite Loaded (1 test)
18+
Test Runner Started
19+
Test Suite Sorted
20+
Test Runner Execution Started (1 test)
21+
Test Suite Started (%s%ephpt-skipif-closing-php-tag.phpt, 1 test)
22+
Test Preparation Started (%s%ephpt-skipif-closing-php-tag.phpt)
23+
Test Prepared (%s%ephpt-skipif-closing-php-tag.phpt)
24+
Test Skipped (%s%ephpt-skipif-closing-php-tag.phpt)
25+
something terrible happened
26+
Test Finished (%s%ephpt-skipif-closing-php-tag.phpt)
27+
Test Suite Finished (%s%ephpt-skipif-closing-php-tag.phpt, 1 test)
28+
Test Runner Execution Finished
29+
Test Runner Finished
30+
PHPUnit Finished (Shell Exit Code: 0)

0 commit comments

Comments
 (0)