-
Notifications
You must be signed in to change notification settings - Fork 21
Fix unit tests and PHP8.1+ compatability #114
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
Conversation
- Switch from standard PHPUnit to yoast polyfill. - Setup sniff dependencies
Version 2 requires PHP7.4
`void` can't be used as a return type in PHP 7.0. The Yoast runner has helpers for this, so switching to those. See: https://github.com/Yoast/PHPUnit-Polyfills#testcases
v4 of the library introduced a few breaking changes. 1) GenerateErrorWrappr requries line to be an int 2) Rollbar\RollbarLogger:: log is now a wrapper around `report` that doesn't return the value that log used to return
Focus on the current stable WordPress, but still include upcoming WP
Add script for updating dependecies
You can see the passing unit tests at https://github.com/aaronjorbin/rollbar-php-wordpress/actions/runs/5512267190 |
The 2,021 files changed is due to
The actual files changed that should be reviewed are and a quick summary for each file:
|
Hi @aaronjorbin, thank you for the massive amount of work you have put into this! It will take me a little bit to review this, but I think this is heading in a good direction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronjorbin Thank you for the work you have put into this. It looks really good! Sorry it took me a bit to go through.
Description of the change
Fix #113 and #102
This updates the unit tests to use the Yoast Pollyfill and also wp-env for testing across multiple versions of PHP.
The underlying rollbar-php is both updated and kept the same. It's updated for sites running PHP8+, but kept the same for PHP7. This introduces a bit of technical debt as the actual dependencies aren't in the composer file but instead are in the
php7
andphp8
folder. To help manage that, a script is included for updating those dependencies.There are a few spots in the code that now also include PHP version specific code. When php7 support is dropped, these will need to be cleaned up.
Additionally, github actions are added in order to allow unit tests to run across multiple versions of PHP
Testing Instructions
If you want to test this change manually, you can use wp-env. clone the repo and make sure git, docker, and node are installed on your machine. Then run
npm install
WP_ENV_PHP_VERSION="7.0" npm run wp-env start -- --update
to start with PHP 7.0You can login to Wordpress at http://localhost:8888/ with the username
admin
and the passwordpassword
If you want to test a different version of PHP, you can restart the env with a different PHP version passed in. For example,
WP_ENV_PHP_VERSION="8.2" npm run wp-env start -- --update
to start with PHP 8.2Type of change
Checklists
Development
Code review