Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@treffynnon
Copy link
Collaborator

@yan12125
Copy link

Two steps allow tests to run with phpunit 8.5 and php 8.1:

  • Replace PHPUnit_Framework_TestCase with \PHPUnit\Framework\TestCase in all test files
  • Add return type declaration : void to setUp() and tearDown() in all test classes

For 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

@treffynnon
Copy link
Collaborator Author

Nice - thanks for your help - I think we have a PR we can merge now.

@treffynnon treffynnon merged commit 6da4e7e into master Jul 18, 2022
@treffynnon treffynnon deleted the aaronpk-master branch July 18, 2022 03:49
@yan12125
Copy link

Glad to help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants