Skip to content

Commit

Permalink
Merge pull request #33143 from mdeweerd/fix/commonclasstest.nologfile
Browse files Browse the repository at this point in the history
Qual: Fix CommanClassTest in case there is no logfile
  • Loading branch information
eldy authored Feb 19, 2025
2 parents 373df20 + 1811ea7 commit 6f240d9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/phpunit/CommonClassTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ protected function onNotSuccessfulTest(Throwable $t): void

// Get the lines that were added since the start of the test

$filecontent = (string) @file_get_contents($this->logfile);
if (file_exists($this->logfile)) {
$filecontent = (string) @file_get_contents($this->logfile);
} else {
$filecontent = '';
}

$currentSize = strlen($filecontent);
if ($currentSize >= $this->logSizeAtSetup) {
$filecontent = substr($filecontent, $this->logSizeAtSetup);
Expand Down Expand Up @@ -214,7 +219,11 @@ protected function setUp(): void
$db = $this->savdb;

// Record the filesize to determine which part of the log to show on error
$this->logSizeAtSetup = (int) filesize($this->logfile);
if (file_exists($this->logfile)) {
$this->logSizeAtSetup = (int) filesize($this->logfile);
} else {
$this->logSizeAtSetup = 0;
}

if ((int) getenv('PHPUNIT_DEBUG') > 0) {
print get_called_class().'::'.$this->getName(false)."::".__FUNCTION__.PHP_EOL;
Expand Down

0 comments on commit 6f240d9

Please sign in to comment.