Skip to content

Commit 786d474

Browse files
mvoriseksebastianbergmann
authored andcommitted
mark test as incomplete if error_log file cannot be created
1 parent a1228c3 commit 786d474

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/Framework/TestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,8 @@ private function runTest(): mixed
13281328
print $this->stripDateFromErrorLog($errorLogOutput);
13291329
}
13301330
}
1331+
} elseif ($this->expectErrorLog) {
1332+
$this->markTestIncomplete('Could not create writable error_log file.');
13311333
}
13321334
} catch (Throwable $exception) {
13331335
if ($capture !== false) {

tests/end-to-end/generic/expect-error-log-fail-with-open_basedir.phpt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ $_SERVER['argv'][] = __DIR__ . '/_files/ExpectErrorLogFailTest.php';
1313
* - https://github.com/php/php-src/issues/17817
1414
* - https://github.com/php/php-src/issues/18530
1515
*
16-
* Until then, ignore TestCase::expectErrorLog() if open_basedir php.ini is in effect.
16+
* Until then, mark the test result as incomplete when TestCase::expectErrorLog() was called and an error_log file
17+
* could not be created (because of open_basedir php.ini in effect, readonly filesystem...).
1718
*/
1819

1920
ini_set('open_basedir', (ini_get('open_basedir') ? ini_get('open_basedir') . PATH_SEPARATOR : '') . dirname(__DIR__, 3));
@@ -26,11 +27,16 @@ PHPUnit %s by Sebastian Bergmann and contributors.
2627

2728
Runtime: %s
2829

29-
. 1 / 1 (100%)
30+
I 1 / 1 (100%)
3031

3132
Time: %s, Memory: %s
3233

3334
Expect Error Log Fail (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFail)
34-
✔ One
35+
∅ One
36+
37+
│ Could not create writable error_log file.
3538

36-
OK (1 test, 1 assertion)
39+
40+
41+
OK, but there were issues!
42+
Tests: 1, Assertions: 1, Incomplete: 1.

tests/end-to-end/generic/expect-error-log-with-open_basedir.phpt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ PHPUnit %s by Sebastian Bergmann and contributors.
1818
Runtime: %s
1919

2020
logged a side effect
21-
. 1 / 1 (100%)
21+
I 1 / 1 (100%)
2222

2323
Time: %s, Memory: %s
2424

2525
Expect Error Log (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLog)
26-
✔ One
26+
∅ One
27+
28+
│ Could not create writable error_log file.
2729

28-
OK (1 test, 1 assertion)
30+
31+
32+
OK, but there were issues!
33+
Tests: 1, Assertions: 1, Incomplete: 1.

0 commit comments

Comments
 (0)