Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to run tests in PHP 8 #1760

Merged
merged 20 commits into from Jan 11, 2024
Merged

Conversation

psrpinto
Copy link
Contributor

@psrpinto psrpinto commented Jan 10, 2024

Problem

It was not possible to run tests under PHP 8 because PHPUnit's version that we were using (^7) does not support PHP 8. The earliest PHPUnit version that supports PHP 8 is 9.3.

Solution

Upgrade PHPUnit to ^9.6 (9.6 is the latest minor version of PHPUnit 9).

Changes to GitHub actions

GitHub actions have been modified to run tests for multisite on and multisite off, on latest and nightly, and on both 7.4 and 8.3. Coverage runs only on 8.3.

Screenshot 2024-01-11 at 14 52 09

Helper scripts for running tests in wp-env

Two new npm scripts have been added to facilitate running tests in the wp-env's tests-cli container:

  • npm run env:tests: Runs composer install and then runs tests
  • npm run env:tests-cmd: Facilitates running arbitrary commands in the tests container, e.g. run a single test:
    • npm run env:tests-cmd vendor/bin/phpunit -- --filter test_multiple_imports_singular

To-do

  • Upgrade PHPUnit to ^8. PHPUnit 8's release notes.
  • Fix issues that caused tests to fail under PHPUnit ^8
  • Fix deprecations introduced by PHPUnit ^8
  • Upgrade PHPUnit to ^9. PHPUnit 9's release notes.
  • Fix deprecations introduced by PHPUnit ^9
  • Make sure tests run in wp-env under PHP 8
  • Make GitHub workflow also test under PHP 8

Testing Instructions

  1. npm run env:start
  2. npm run env:tests

@psrpinto psrpinto changed the title Make it possible to run tests when using PHP 8 Make it possible to run tests in PHP 8 Jan 10, 2024
@psrpinto psrpinto force-pushed the tests-php8 branch 5 times, most recently from b01a8e4 to ad3385b Compare January 10, 2024 15:54
@psrpinto psrpinto marked this pull request as ready for review January 10, 2024 16:16
@psrpinto
Copy link
Contributor Author

psrpinto commented Jan 10, 2024

This is ready for review. All checks in the PR are passing, it's not marked as "checked" because repository settings need to be changed so that required checks are not using PHP 7.4 (please see To-do in PR description).

amieiro
amieiro previously approved these changes Jan 11, 2024
Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@amieiro amieiro self-requested a review January 11, 2024 16:47
@amieiro amieiro merged commit 33ba504 into GlotPress:develop Jan 11, 2024
11 checks passed
@psrpinto psrpinto deleted the tests-php8 branch January 11, 2024 17:51
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.

None yet

3 participants