Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 4d09630

Browse files
authored
Merge pull request #47 from Codeception/phpunit-7.4
Support PhpUnit 7.4
2 parents a5633c7 + cbf95f4 commit 4d09630

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"phpunit/phpunit": "~7.1.0|~7.2.0|~7.3.0",
13+
"phpunit/phpunit": ">=7.1 <7.5",
1414
"phpunit/php-code-coverage": "^6.0",
1515
"sebastian/comparator": "^3.0",
1616
"sebastian/diff": "^3.0"

src/Log/JUnit.php

100644100755
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Codeception\Configuration;
55
use Codeception\Test\Interfaces\Reported;
66
use Codeception\Test\Test;
7+
use PHPUnit\Framework\TestCase;
78

89
class JUnit extends \PHPUnit\Util\Log\JUnit
910
{
@@ -39,6 +40,24 @@ public function endTest(\PHPUnit\Framework\Test $test, float $time):void
3940
$numAssertions
4041
);
4142
}
42-
parent::endTest($test, $time);
43+
44+
if ($test instanceof TestCase) {
45+
parent::endTest($test, $time);
46+
return;
47+
}
48+
49+
// since PhpUnit 7.4.0, parent::endTest ignores tests that aren't instances of TestCase
50+
// so I copied this code from PhpUnit 7.3.5
51+
52+
$this->currentTestCase->setAttribute(
53+
'time',
54+
\sprintf('%F', $time)
55+
);
56+
$this->testSuites[$this->testSuiteLevel]->appendChild(
57+
$this->currentTestCase
58+
);
59+
$this->testSuiteTests[$this->testSuiteLevel]++;
60+
$this->testSuiteTimes[$this->testSuiteLevel] += $time;
61+
$this->currentTestCase = null;
4362
}
4463
}

0 commit comments

Comments
 (0)