Skip to content

Commit cc6414a

Browse files
Mark a test as errored (instead of skipped) when the file for error_log() capturing cannot be created
1 parent ca4db79 commit cc6414a

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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\Framework;
11+
12+
/**
13+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
14+
*
15+
* @internal This class is not covered by the backward compatibility promise for PHPUnit
16+
*/
17+
final class ErrorLogNotWritableException extends Exception
18+
{
19+
public function __construct()
20+
{
21+
parent::__construct('Could not create writable file for error_log()');
22+
}
23+
}

src/Framework/TestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2335,11 +2335,14 @@ private function startErrorLogCapture(): void
23352335
$this->previousErrorLogTarget = ini_set('error_log', $capturePath);
23362336
}
23372337

2338+
/**
2339+
* @throws ErrorLogNotWritableException
2340+
*/
23382341
private function verifyErrorLogExpectation(): void
23392342
{
23402343
if ($this->errorLogCapture === false) {
23412344
if ($this->expectErrorLog) {
2342-
$this->markTestIncomplete('Could not create writable file for error_log()');
2345+
throw new ErrorLogNotWritableException;
23432346
}
23442347

23452348
return;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ Test Runner Execution Started (1 test)
3333
Test Suite Started (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFailTest, 1 test)
3434
Test Preparation Started (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFailTest::testOne)
3535
Test Prepared (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFailTest::testOne)
36-
Test Marked Incomplete (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFailTest::testOne)
36+
Test Errored (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFailTest::testOne)
3737
Could not create writable file for error_log()
3838
Test Finished (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFailTest::testOne)
3939
Test Suite Finished (PHPUnit\TestFixture\ExpectNoErrorLog\ExpectErrorLogFailTest, 1 test)
4040
Test Runner Execution Finished
4141
Test Runner Finished
42-
PHPUnit Finished (Shell Exit Code: 0)
42+
PHPUnit Finished (Shell Exit Code: 2)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Test Suite Started (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLogTest, 1 tes
2424
Test Preparation Started (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLogTest::testOne)
2525
Test Prepared (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLogTest::testOne)
2626
logged a side effect
27-
Test Marked Incomplete (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLogTest::testOne)
27+
Test Errored (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLogTest::testOne)
2828
Could not create writable file for error_log()
2929
Test Finished (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLogTest::testOne)
3030
Test Suite Finished (PHPUnit\TestFixture\ExpectErrorLog\ExpectErrorLogTest, 1 test)
3131
Test Runner Execution Finished
3232
Test Runner Finished
33-
PHPUnit Finished (Shell Exit Code: 0)
33+
PHPUnit Finished (Shell Exit Code: 2)

0 commit comments

Comments
 (0)