Closed treffynnon closed 2 years ago
Two steps allow tests to run with phpunit 8.5 and php 8.1:
PHPUnit_Framework_TestCase
with \PHPUnit\Framework\TestCase
in all test files: void
to setUp() and tearDown() in all test classesFor the first step, source-level compatibility for newer and older phpunit can be achieved by
+if (!class_exists('PHPUnit_Framework_TestCase')) {
+ class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
+}
However, for the second step, source-level compatibility seems impossible for both newer and older PHP. PHP >= 8.0 requires compatible return types [1], while PHP < 7.0 does not recognize return types [2]. I'm afraid idiorm needs to use a magic like sed -i 's#: void##' test/*.php
before running tests for older PHP versions.
[1] https://php.watch/versions/8.0/lsp-errors [2] https://www.php.net/manual/en/migration70.new-features.php
Nice - thanks for your help - I think we have a PR we can merge now.
Glad to help :)