Skip to content

Commit 43aa02a

Browse files
Merge branch '12.1'
2 parents df069d9 + a6ae2e2 commit 43aa02a

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/Framework/TestCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,13 @@ private function runTest(): mixed
12681268
print preg_replace('/\[.+\] /', '', $errorLogOutput);
12691269
}
12701270
} catch (Throwable $exception) {
1271+
if (!$this->expectErrorLog) {
1272+
$errorLogOutput = stream_get_contents($capture);
1273+
1274+
// strip date from logged error, see https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
1275+
print preg_replace('/\[.+\] /', '', $errorLogOutput);
1276+
}
1277+
12711278
if (!$this->shouldExceptionExpectationsBeVerified($exception)) {
12721279
throw $exception;
12731280
}

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6173
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/6173/Issue6173Test.php';
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+
hello, success!
18+
.hello, fail!
19+
F 2 / 2 (100%)
20+
21+
Time: %s, Memory: %s
22+
23+
There was 1 failure:
24+
25+
1) PHPUnit\TestFixture\Issue6173\Issue6173Test::test_log_fail
26+
Failed asserting that false is true.
27+
28+
%sIssue6173Test.php:%d
29+
30+
FAILURES!
31+
Tests: 2, Assertions: 2, Failures: 1.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
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\Issue6173;
11+
12+
use function error_log;
13+
use PHPUnit\Framework\TestCase;
14+
15+
final class Issue6173Test extends TestCase
16+
{
17+
public function test_log_success(): void
18+
{
19+
error_log('hello, success!');
20+
$this->assertTrue(true);
21+
}
22+
23+
public function test_log_fail(): void
24+
{
25+
error_log('hello, fail!');
26+
$this->assertTrue(false);
27+
}
28+
}

0 commit comments

Comments
 (0)