#56219 closed defect (bug) (invalid)
Importer plugin's PHPUnit tests fail on PHP 8.1
Reported by: | antonvlasenko | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Import | Keywords: | has-patch |
Focuses: | Cc: |
Description
Steps to reproduce this bug:
- Make sure you are on PHP 8.1
- Install the importer plugin from the official repository: https://github.com/WordPress/wordpress-importer
- Install composer dependencies (you might have to use --ingore-platform-reqs option).
- Run test suite that is shipped with the importer plugin.
Expected result:
All PHPUnit tests pass.
Actual result:
PHPUnit tests fail with this error message:
PHP Fatal error: During inheritance of ArrayAccess: Uncaught Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice ...
Change History (10)
This ticket was mentioned in PR #2977 on WordPress/wordpress-develop by anton-vlasenko.
2 years ago
#1
- Keywords has-patch added
This ticket was mentioned in Slack in #core-php by antonvlasenko. View the logs.
2 years ago
#4
@
2 years ago
One small remark:
I had to use PHPUnit, which is shipped with Core during testing.
PHPUnit that is included with the importer plugin doesn't support PHP 8.1.
E.g., when you are in the importer plugin's folder, you have to run the test suite like that:
php ./../../../../vendor/bin/phpunit -c phpunit.xml.dist
#5
@
2 years ago
@antonvlasenko Couple of points here:
- The changes you are suggesting are for an external dependency. That dependency has already released a version compatible with PHP 8.1 (and 8.2 for that matter). WP just hasn't upgraded yet. See: #54504.
- The only reason the Importer plugin has a PHPUnit restriction is because it is needed to support older WP versions. With WP 5.9 or higher, all necessary PHPUnit versions are supported. You should NOT run with
--ignore-platform-reqs
. Instead you should runcomposer remove --dev phpunit/phpunit
(this will not actually remove phpunit, but will remove the version restriction). See: https://github.com/WordPress/wordpress-importer/blob/c0e188a85c57fadde914e397bd4b0a9c104e5f17/.github/workflows/test.yml#L108-L146 for the full details and explanation.
I suggest closing this ticket as a duplicate of #54504.
#6
@
2 years ago
- Resolution set to invalid
- Status changed from new to closed
@jrf
Sorry, I didn't know it's an external dependency.
Of course, let's close this ticket in favor of #54504 (especially if it can bring PHP namespaces to WordPress).
You should NOT run with
--ignore-platform-reqs
. Instead you should runcomposer remove --dev phpunit/phpunit
--ignore-platform-reqs
worked for me and I didn't feel the need to modify composer.json
, but thanks for the hint.
anton-vlasenko commented on PR #2977:
2 years ago
#7
Thank you for the feedback, @jrfnl !
I'm closing this ticket. See https://core.trac.wordpress.org/ticket/56219#comment:6 for more details.
#8
@
2 years ago
--ignore-platform-reqs worked for me and I didn't feel the need to modify composer.json, but thanks for the hint.
I understand and it is a logical option to use.
The setup for integration tests for plugins can be complex as they normally support multiple WP versions and not all WP versions support the complete range of PHPUnit versions needed for the PHP versions supported.
If you're interested in understanding more about this, this blog post is probably a good starting point: Changes to the WordPress Core PHP Test Suite and the underlying ticket: #46149.
This PR aims to fix failing unit test that are shipped with the WordPress importer plugin.
Trac ticket: https://core.trac.wordpress.org/ticket/56219#ticket