Skip to content

Commit

Permalink
fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Feb 15, 2025
1 parent f175085 commit 5b5c7ee
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use function ob_get_level;
use function ob_start;
use function preg_match;
use function preg_replace;
use function restore_error_handler;
use function restore_exception_handler;
use function set_error_handler;
Expand Down Expand Up @@ -180,7 +181,6 @@ abstract class TestCase extends Assert implements Reorderable, SelfDescribing, T
private int $outputBufferingLevel;
private bool $outputRetrievedForAssertion = false;
private bool $doesNotPerformAssertions = false;
private string $errorLogOutput = '';
private bool $expectsErrorLog = false;
private ?string $errorLogPrevious = null;

Expand Down Expand Up @@ -570,12 +570,6 @@ final public function runBare(): void
$this->performAssertionsOnOutput();
}

if ($this->expectsErrorLog) {
$this->assertNotEmpty($this->errorLogOutput);
} else {
$this->assertEmpty($this->errorLogOutput);
}

try {
$this->mockObjects = [];

Expand Down Expand Up @@ -1130,6 +1124,15 @@ final protected function runTest(): mixed

try {
$testResult = $this->{$this->methodName}(...$testArguments);

$errorLogOutput = stream_get_contents($this->errorLogResource);

if ($this->expectsErrorLog) {
$this->assertNotEmpty($errorLogOutput);
} else {
// strip date from logged error, see https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
print preg_replace('/\[.+\] /', '', $errorLogOutput);
}
} catch (Throwable $exception) {
if (!$this->shouldExceptionExpectationsBeVerified($exception)) {
throw $exception;
Expand Down Expand Up @@ -1479,7 +1482,6 @@ private function startOutputBuffering(): void
private function stopOutputBuffering(): bool
{
if ($this->errorLogResource !== null) {
$this->errorLogOutput = stream_get_contents($this->errorLogResource);
fclose($this->errorLogResource);
}

Expand Down

0 comments on commit 5b5c7ee

Please sign in to comment.