Skip to content

Commit

Permalink
fix TestCase::onNotSuccessfulTest() for PHP 8.0 and lower
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Feb 18, 2023
1 parent 351a15b commit c8c12b5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Phpunit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@
use PHPUnit\Util\Test as TestUtil;
use SebastianBergmann\CodeCoverage\CodeCoverage;

if (\PHP_VERSION_ID < 81_000) {
trait Phpunit9xTestCaseTrait
{
protected function onNotSuccessfulTest(\Throwable $e): void
{
$this->_onNotSuccessfulTest($e);
}
}
} else {
trait Phpunit9xTestCaseTrait
{
protected function onNotSuccessfulTest(\Throwable $e): never
{
$this->_onNotSuccessfulTest($e);
}
}
}

/**
* Generic TestCase for PHPUnit tests for ATK4 repos.
*/
abstract class TestCase extends BaseTestCase
{
use Phpunit9xTestCaseTrait;
use WarnDynamicPropertyTrait;

protected function setUp(): void
Expand Down Expand Up @@ -171,7 +190,7 @@ private function releaseObjectsFromExceptionTrace(\Throwable $e): void
}
}

protected function onNotSuccessfulTest(\Throwable $e): void
protected function _onNotSuccessfulTest(\Throwable $e): void
{
// release objects from uncaught exception as it is never released
$this->releaseObjectsFromExceptionTrace($e);
Expand Down

0 comments on commit c8c12b5

Please sign in to comment.