Skip to content

Fix test bootstrap on PHP 8.6 - #3193

Open
faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/php86-test-bootstrap
Open

faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/php86-test-bootstrap

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

Changes Proposed in this Pull Request

  • On PHP 8.6, vendor/bin/phpunit stops before any test runs. The bootstrap turns every error into an exception while the plugin loads, and the WordPress test library calls spl_object_hash(), which is now deprecated:

    Error in bootstrap script: Exception:
    PHP Deprecated: Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead in .../wordpress-tests-lib/includes/functions.php on line 100
    
  • tests/php/bootstrap.php: the handler already skipped deprecations from /vendor/. It now also skips deprecations from files inside WP_TESTS_DIR. Deprecations from plugin code still stop the run, which is how the namespace constant issue in Fix PHP 8.6 deprecation for class constant named namespace #3191 was found.

  • composer.lock: bumped amphp/amp from v2.6.2 to v2.6.5 and amphp/byte-stream from v1.8.1 to v1.8.2. These are dev dependencies of Psalm. The old amp prints an implicit-nullable deprecation on PHP 8.4+, and the 16 tests with @runInSeparateProcess read that output as an error.

Testing Instructions

  1. Use PHP 8.6 with the usual test setup (bin/install-wp-tests.sh, WP_TESTS_DIR set).
  2. On trunk, run composer install and vendor/bin/phpunit. You get "Error in bootstrap script" and no test runs.
  3. Check out this branch, run composer install, then vendor/bin/phpunit.
  4. Expected: the bootstrap now loads. On this branch alone it stops on the plugin's own namespace constant deprecation, which Fix PHP 8.6 deprecation for class constant named namespace #3191 fixes. With Fix PHP 8.6 deprecation for class constant named namespace #3191 and Use is_int() in stats to fix PHP 8.6 deprecation #3192 applied, the full suite passes.
  5. Run vendor/bin/phpunit on PHP 8.2. Expected: same result as on trunk.

Automated: PHP 8.6 with #3191 and #3192 applied gives 1258 tests OK, 3 skipped (Geocode). PHP 8.2 on this branch gives 1257 tests OK, 3 skipped. Psalm runs clean with the new amp, and PHPCS is clean on the bootstrap.

No end-user changes, so no release notes.

This branch has not been deployed

No deployments
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.

1 participant