Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests and dev environment for PHPUnit9 (#1172)
* Remove unused PHPUnit7 files * WP-r51570: Build/Test Tools: Alias the `Getopt` class conditionally, as the class no longer exists in PHPUnit 9.x. Most of the aliasing in this `compat.php` file is redundant as PHPUnit 5.7.21+ contains a forward compatibility layer for these classes anyway (= PHPUnit provides both the namespaced and underscore named versions of these classes in PHPUnit 5.7.21+). All the same, the file and the aliases are left in place for the time being, as plugins/themes using the WP test suite as the basis for their integration tests may rely on it, though WP itself should not really need it anymore, save for maybe one or two classes. Follow-up to https://core.trac.wordpress.org/log/?revs=51559-51569. WP:Props jrf. See https://core.trac.wordpress.org/ticket/46149. Conflicts: - tests/phpunit/includes/phpunit6/compat.php --- Merges https://core.trac.wordpress.org/changeset/51570 / WordPress/wordpress-develop@fcd4aa4700 to ClassicPress. * Fix merge conflicts from 51570 * WP-r51462: Tests: Replace `assertContains()` with `assertStringContainsString()` when used with strings. Using the `assertContains()` and `assertNotContains()` methods with string haystacks was deprecated in PHPUnit 8 and removed in PHPUnit 9. While WordPress test suite currently only supports PHPUnit up to 7.5.x, this allows us to switch to newer assertions ahead of adding full support for PHPUnit 8+. These methods introduced in PHPUnit 7.5 should be used as an alternative: * `assertStringContainsString()` * `assertStringContainsStringIgnoringCase` * `assertStringNotContainsString()` * `assertStringNotContainsStringIgnoringCase` As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods were added to the `WP_UnitTestCase` class for PHPUnit < 7.5. Follow-up to https://core.trac.wordpress.org/changeset/51331, https://core.trac.wordpress.org/changeset/51451, https://core.trac.wordpress.org/changeset/51461. WP:Props jrf, dd32, SergeyBiryukov. See https://core.trac.wordpress.org/ticket/53363, https://core.trac.wordpress.org/ticket/46149. Conflicts: - tests/phpunit/tests/admin/includesListTable.php - tests/phpunit/tests/admin/includesTemplate.php - tests/phpunit/tests/admin/wpPrivacyRequestsTable.php - tests/phpunit/tests/blocks/block-editor.php - tests/phpunit/tests/blocks/render.php - tests/phpunit/tests/category/wpListCategories.php - tests/phpunit/tests/comment.php - tests/phpunit/tests/comment/commentForm.php - tests/phpunit/tests/comment/getCommentReplyLink.php - tests/phpunit/tests/comment/query.php - tests/phpunit/tests/customize/nav-menus.php - tests/phpunit/tests/customize/widgets.php - tests/phpunit/tests/formatting/MakeClickable.php - tests/phpunit/tests/l10n.php - tests/phpunit/tests/media.php - tests/phpunit/tests/meta/query.php - tests/phpunit/tests/post/output.php - tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php - tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php - tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php - tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php - tests/phpunit/tests/query/invalidQueries.php - tests/phpunit/tests/rest-api/rest-attachments-controller.php - tests/phpunit/tests/rest-api/rest-block-renderer-controller.php - tests/phpunit/tests/rest-api/rest-posts-controller.php - tests/phpunit/tests/rest-api/rest-revisions-controller.php - tests/phpunit/tests/rest-api/rest-tags-controller.php - tests/phpunit/tests/robots.php - tests/phpunit/tests/sitemaps/sitemaps.php - tests/phpunit/tests/term/getTermLink.php - tests/phpunit/tests/term/wpGenerateTagCloud.php - tests/phpunit/tests/user/author.php - tests/phpunit/tests/user/wpDropdownUsers.php - tests/phpunit/tests/user/wpSendUserRequest.php - tests/phpunit/tests/widgets.php - tests/phpunit/tests/widgets/custom-html-widget.php - tests/phpunit/tests/widgets/media-image-widget.php - tests/phpunit/tests/widgets/media-video-widget.php - tests/phpunit/tests/widgets/text-widget.php - tests/phpunit/tests/widgets/wpWidgetRss.php --- Merges https://core.trac.wordpress.org/changeset/51462 / WordPress/wordpress-develop@c70fe62ed1 to ClassicPress. * Fix merge conflicts from 51462 * WP-r51571: Tests: Fix tests failing due to `assertContains()` using strict checking. Since PHPUnit 8.0.2, the `assertContains()` method, when checking whether a value exists in an array, will do a strict type comparison of the values. This caused a couple of tests to fail. Using the correct data type in the test fixes that. References: * https://github.com/sebastianbergmann/phpunit/blob/8.0.6/ChangeLog-8.0.mdhttps://core.trac.wordpress.org/ticket/802---2019-02-07 * sebastianbergmann/phpunit#3511 * sebastianbergmann/phpunit@6205f33 Follow-up to https://core.trac.wordpress.org/log/?revs=51559-51570. WP:Props jrf. See https://core.trac.wordpress.org/ticket/46149. Conflicts: - tests/phpunit/tests/rest-api/rest-term-meta-fields.php --- Merges https://core.trac.wordpress.org/changeset/51571 / WordPress/wordpress-develop@60dcae95ea to ClassicPress. * Add composer scripts for local tests * Fix composer script for tests * Corrections based on PR review Co-authored-by: Sergey Biryukov <sergeybiryukov@git.wordpress.org>
- Loading branch information