diff --git a/bin/ci/after-wp-install.sh b/bin/ci/after-wp-install.sh index 912a565b104..fa6abbe1d89 100755 --- a/bin/ci/after-wp-install.sh +++ b/bin/ci/after-wp-install.sh @@ -42,41 +42,3 @@ if [[ -n $INSTALL_PWA_PLUGIN ]]; then unzip -d "$WP_CORE_DIR/src/wp-content/plugins/" "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip" echo "done" fi - -if [[ $(php -r "echo PHP_VERSION;") == 8.0* ]]; then - echo "Installing compatible PHPUnit for use with PHP 8..." - - DIFF=$( - cat <<-EOF -diff --git a/composer.json b/composer.json -index 5934aedec..2977df4a9 100644 ---- a/composer.json -+++ b/composer.json -@@ -86,7 +86,17 @@ - ], - "files": [ - "tests/php/register-wp-cli-commands.php", -- "docs/includes/register-wp-cli-commands.php" -+ "docs/includes/register-wp-cli-commands.php", -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/Builder/NamespaceMatch.php", -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/Builder/ParametersMatch.php", -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/InvocationMocker.php", -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/MockMethod.php" -+ ], -+ "exclude-from-classmap": [ -+ "vendor/phpunit/phpunit/src/Framework/MockObject/Builder/NamespaceMatch.php", -+ "vendor/phpunit/phpunit/src/Framework/MockObject/Builder/ParametersMatch.php", -+ "vendor/phpunit/phpunit/src/Framework/MockObject/InvocationMocker.php", -+ "vendor/phpunit/phpunit/src/Framework/MockObject/MockMethod.php" - ] - }, - "repositories": [ - EOF - ) - - echo "${DIFF}" | git apply - - composer require --dev --ignore-platform-reqs --update-with-dependencies phpunit/phpunit:^7.5 - - PATH="$(composer config bin-dir --absolute):$PATH" - echo "done" -fi diff --git a/composer.json b/composer.json index 447bf79b4ab..2d476100790 100644 --- a/composer.json +++ b/composer.json @@ -30,14 +30,14 @@ "php-stubs/wordpress-stubs": "^5.3.2", "phpcompatibility/phpcompatibility-wp": "2.1.1", "phpdocumentor/reflection": "~3.0", - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5", "roave/security-advisories": "dev-latest", "sirbrillig/phpcs-variable-analysis": "2.11.2", "wp-cli/export-command": "^2.0", "wp-cli/extension-command": "^2.0", "wp-cli/wp-cli": "^2.4", "wp-cli/wp-cli-tests": "^3.0.11", - "wp-coding-standards/wpcs": "2.3.0" + "wp-coding-standards/wpcs": "2.3.0", + "yoast/wp-test-utils": "^0.2.2" }, "suggest": { "ext-intl": "Enables use of idn_to_utf8() to convert punycode domains to UTF-8 for use with an AMP Cache.", @@ -58,6 +58,9 @@ } }, "patches": { + "phpunit/phpunit-mock-objects": { + "Fix ReflectionParameter warnings on PHP 8": "patches/phpunit-mock-objects.patch" + }, "sabberworm/php-css-parser": { "1. Add additional validation for size unit ": "https://github.com/sabberworm/PHP-CSS-Parser/compare/3bc5ded67d77a52b81608cfc97f23b1bb0678e2f%5E...468da3441945e9c1bf402a3340b1d8326723f7d9.patch", "2. Validate name-start code points for identifier ": "https://github.com/sabberworm/PHP-CSS-Parser/compare/d42b64793f2edaffeb663c63e9de79069cdc0831%5E...113df5d55e94e21c6402021dfa959924941d4c29.patch", diff --git a/composer.lock b/composer.lock index 057434fa333..e0664b3858f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "656645a4cbfcb362497c45a6f9b26ae0", + "content-hash": "21fc63ecbbc5d31716e574af01f7f472", "packages": [ { "name": "ampproject/amp-toolbox", @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/ampproject/amp-toolbox-php.git", - "reference": "98b020d6961c20689b855675030fabcd14d63a34" + "reference": "a155c37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/98b020d6961c20689b855675030fabcd14d63a34", - "reference": "98b020d6961c20689b855675030fabcd14d63a34", + "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/a155c37", + "reference": "a155c37", "shasum": "" }, "require": { @@ -74,7 +74,7 @@ "issues": "https://github.com/ampproject/amp-toolbox-php/issues", "source": "https://github.com/ampproject/amp-toolbox-php/tree/main" }, - "time": "2021-07-30T01:30:20+00:00" + "time": "2021-08-11T01:48:15+00:00" }, { "name": "cweagans/composer-patches", @@ -231,7 +231,7 @@ "issues": "https://github.com/sabberworm/PHP-CSS-Parser/issues", "source": "https://github.com/sabberworm/PHP-CSS-Parser/tree/master" }, - "time": "2021-07-19T05:52:43+00:00" + "time": "2021-08-01T19:34:12+00:00" }, { "name": "willwashburn/stream", @@ -288,7 +288,7 @@ "packages-dev": [ { "name": "ampproject/php-css-parser-install-plugin", - "version": "dev-update/amp-toolbox-0.7.0-alpha", + "version": "dev-enhancement/phpunit-polyfills", "dist": { "type": "path", "url": "./php-css-parser-install-composer-plugin", @@ -316,6 +316,54 @@ "relative": true } }, + { + "name": "antecedent/patchwork", + "version": "2.1.12", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "b98e046dd4c0acc34a0846604f06f6111654d9ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/b98e046dd4c0acc34a0846604f06f6111654d9ea", + "reference": "b98e046dd4c0acc34a0846604f06f6111654d9ea", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "http://patchwork2.org/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "support": { + "issues": "https://github.com/antecedent/patchwork/issues", + "source": "https://github.com/antecedent/patchwork/tree/2.1.12" + }, + "time": "2019-12-22T17:52:09+00:00" + }, { "name": "automattic/vipwpcs", "version": "2.3.2", @@ -565,6 +613,76 @@ }, "time": "2020-01-14T16:39:13+00:00" }, + { + "name": "brain/monkey", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/Brain-WP/BrainMonkey.git", + "reference": "7042140000b4b18034c0c0010d86274a00f25442" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/7042140000b4b18034c0c0010d86274a00f25442", + "reference": "7042140000b4b18034c0c0010d86274a00f25442", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.0", + "mockery/mockery": ">=0.9 <2", + "php": ">=5.6.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || ^0.7", + "phpcompatibility/php-compatibility": "^9.3.0", + "phpunit/phpunit": "^5.7.9 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Brain\\Monkey\\": "src/" + }, + "files": [ + "inc/api.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "Monkey Patching", + "interception", + "mock", + "mock functions", + "mockery", + "patchwork", + "redefinition", + "runkit", + "test", + "testing" + ], + "support": { + "issues": "https://github.com/Brain-WP/BrainMonkey/issues", + "source": "https://github.com/Brain-WP/BrainMonkey" + }, + "time": "2020-10-13T17:56:14+00:00" + }, { "name": "civicrm/composer-downloads-plugin", "version": "v3.0.1", @@ -1307,6 +1425,57 @@ }, "time": "2021-04-26T09:17:50+00:00" }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" + }, { "name": "mikey179/vfsstream", "version": "v1.6.9", @@ -1358,6 +1527,75 @@ }, "time": "2021-07-16T08:08:02+00:00" }, + { + "name": "mockery/mockery", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "31467aeb3ca3188158613322d66df81cedd86626" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/31467aeb3ca3188158613322d66df81cedd86626", + "reference": "31467aeb3ca3188158613322d66df81cedd86626", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "issues": "https://github.com/mockery/mockery/issues", + "source": "https://github.com/mockery/mockery/tree/1.3.4" + }, + "time": "2021-02-24T09:51:00+00:00" + }, { "name": "monolog/monolog", "version": "1.26.1", @@ -3030,12 +3268,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "52a126190a36bc9236846f5d42e10bff9ff60d72" + "reference": "6da216d969efa7e52cc7d0af125b8c8bb9caed25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/52a126190a36bc9236846f5d42e10bff9ff60d72", - "reference": "52a126190a36bc9236846f5d42e10bff9ff60d72", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/6da216d969efa7e52cc7d0af125b8c8bb9caed25", + "reference": "6da216d969efa7e52cc7d0af125b8c8bb9caed25", "shasum": "" }, "conflict": { @@ -3068,7 +3306,7 @@ "composer/composer": "<1.10.22|>=2-alpha.1,<2.0.13", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/core": ">=2,<3.5.39", - "contao/core-bundle": ">=4,<4.4.52|>=4.5,<4.9.16|>=4.10,<4.11.5|= 4.10.0", + "contao/core-bundle": ">=4,<4.4.56|>=4.5,<4.9.18|>=4.10,<4.11.7|= 4.10.0", "contao/listing-bundle": ">=4,<4.4.8", "craftcms/cms": "<3.6.7", "croogo/croogo": "<3.0.7", @@ -3085,7 +3323,7 @@ "doctrine/mongodb-odm": ">=1,<1.0.2", "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1|>=2.8.3,<2.8.4", - "dolibarr/dolibarr": "<11.0.4", + "dolibarr/dolibarr": "<14", "dompdf/dompdf": ">=0.6,<0.6.2", "drupal/core": ">=7,<7.80|>=8,<8.9.14|>=9,<9.0.12|>=9.1,<9.1.7", "drupal/drupal": ">=7,<7.80|>=8,<8.9.14|>=9,<9.0.12|>=9.1,<9.1.7", @@ -3132,6 +3370,7 @@ "gos/web-socket-bundle": "<1.10.4|>=2,<2.6.1|>=3,<3.3", "gree/jose": "<=2.2", "gregwar/rst": "<1.0.3", + "grumpydictator/firefly-iii": "<5.5.13", "guzzlehttp/guzzle": ">=4-rc.2,<4.2.4|>=5,<5.3.1|>=6,<6.2.1", "illuminate/auth": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.10", "illuminate/cookie": ">=4,<=4.0.11|>=4.1,<=4.1.99999|>=4.2,<=4.2.99999|>=5,<=5.0.99999|>=5.1,<=5.1.99999|>=5.2,<=5.2.99999|>=5.3,<=5.3.99999|>=5.4,<=5.4.99999|>=5.5,<=5.5.49|>=5.6,<=5.6.99999|>=5.7,<=5.7.99999|>=5.8,<=5.8.99999|>=6,<6.18.31|>=7,<7.22.4", @@ -3153,6 +3392,7 @@ "laminas/laminas-http": "<2.14.2", "laravel/framework": "<6.20.26|>=7,<8.40", "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", + "lavalite/cms": "<=5.8", "league/commonmark": "<0.18.3", "league/flysystem": "<1.1.4|>=2,<2.1.1", "lexik/jwt-authentication-bundle": "<2.10.7|>=2.11,<2.11.3", @@ -3198,7 +3438,7 @@ "paragonie/random_compat": "<2", "passbolt/passbolt_api": "<2.11", "paypal/merchant-sdk-php": "<3.12", - "pear/archive_tar": "<1.4.12", + "pear/archive_tar": "<1.4.14", "personnummer/personnummer": "<3.0.2", "phanan/koel": "<5.1.4", "phpfastcache/phpfastcache": ">=5,<5.0.13", @@ -3309,12 +3549,13 @@ "thelia/thelia": ">=2.1-beta.1,<2.1.3", "theonedemon/phpwhois": "<=4.2.5", "titon/framework": ">=0,<9.9.99", + "topthink/think": "<=6.0.9", "tribalsystems/zenario": "<8.8.53370", "truckersmp/phpwhois": "<=4.3.1", "twig/twig": "<1.38|>=2,<2.7", - "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.32|>=8,<8.7.38|>=9,<9.5.28|>=10,<10.4.18|>=11,<11.3.1", + "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.32|>=8,<8.7.38|>=9,<9.5.29|>=10,<10.4.19|>=11,<11.3.2", "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", - "typo3/cms-core": ">=6.2,<=6.2.56|>=7,<7.6.52|>=8,<8.7.41|>=9,<9.5.28|>=10,<10.4.18|>=11,<11.3.1", + "typo3/cms-core": ">=6.2,<=6.2.56|>=7,<7.6.52|>=8,<8.7.41|>=9,<9.5.29|>=10,<10.4.19|>=11,<11.3.2", "typo3/cms-form": ">=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.3.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<3.3.23|>=4,<4.0.17|>=4.1,<4.1.16|>=4.2,<4.2.12|>=4.3,<4.3.3", @@ -3402,7 +3643,7 @@ "type": "tidelift" } ], - "time": "2021-07-26T22:02:34+00:00" + "time": "2021-08-11T16:04:32+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -3914,7 +4155,6 @@ "issues": "https://github.com/sebastianbergmann/resource-operations/issues", "source": "https://github.com/sebastianbergmann/resource-operations/tree/master" }, - "abandoned": true, "time": "2015-07-28T20:34:47+00:00" }, { @@ -5527,16 +5767,16 @@ }, { "name": "wp-cli/extension-command", - "version": "v2.1.1", + "version": "v2.1.2", "source": { "type": "git", "url": "https://github.com/wp-cli/extension-command.git", - "reference": "87c9e33154cf02da35a690d2b56b083125d71493" + "reference": "a0159174d1dfa4725ac7c1e8b7e0609ba39495d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/extension-command/zipball/87c9e33154cf02da35a690d2b56b083125d71493", - "reference": "87c9e33154cf02da35a690d2b56b083125d71493", + "url": "https://api.github.com/repos/wp-cli/extension-command/zipball/a0159174d1dfa4725ac7c1e8b7e0609ba39495d8", + "reference": "a0159174d1dfa4725ac7c1e8b7e0609ba39495d8", "shasum": "" }, "require": { @@ -5617,9 +5857,9 @@ "homepage": "https://github.com/wp-cli/extension-command", "support": { "issues": "https://github.com/wp-cli/extension-command/issues", - "source": "https://github.com/wp-cli/extension-command/tree/v2.1.1" + "source": "https://github.com/wp-cli/extension-command/tree/v2.1.2" }, - "time": "2021-07-26T08:17:56+00:00" + "time": "2021-08-06T13:32:40+00:00" }, { "name": "wp-cli/mustangostang-spyc", @@ -5732,12 +5972,12 @@ "source": { "type": "git", "url": "https://github.com/wp-cli/wp-cli.git", - "reference": "f40c35936e7a8faa59f12ba1fc7cbeb6082d03ca" + "reference": "da03bb1e8e929fe42a8f9e3814ef284028ee33fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/f40c35936e7a8faa59f12ba1fc7cbeb6082d03ca", - "reference": "f40c35936e7a8faa59f12ba1fc7cbeb6082d03ca", + "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/da03bb1e8e929fe42a8f9e3814ef284028ee33fc", + "reference": "da03bb1e8e929fe42a8f9e3814ef284028ee33fc", "shasum": "" }, "require": { @@ -5796,7 +6036,7 @@ "issues": "https://github.com/wp-cli/wp-cli/issues", "source": "https://github.com/wp-cli/wp-cli" }, - "time": "2021-07-28T06:19:49+00:00" + "time": "2021-08-06T13:54:16+00:00" }, { "name": "wp-cli/wp-cli-tests", @@ -5974,16 +6214,16 @@ }, { "name": "yoast/phpunit-polyfills", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", - "reference": "5d257d5a6977137016f3df440ce640ce72ffd61a" + "reference": "f014fb21c2b0038fd329515d59025af42fb98715" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/5d257d5a6977137016f3df440ce640ce72ffd61a", - "reference": "5d257d5a6977137016f3df440ce640ce72ffd61a", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/f014fb21c2b0038fd329515d59025af42fb98715", + "reference": "f014fb21c2b0038fd329515d59025af42fb98715", "shasum": "" }, "require": { @@ -6033,7 +6273,73 @@ "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", "source": "https://github.com/Yoast/PHPUnit-Polyfills" }, - "time": "2021-06-21T03:13:22+00:00" + "time": "2021-08-09T16:28:08+00:00" + }, + { + "name": "yoast/wp-test-utils", + "version": "0.2.2", + "source": { + "type": "git", + "url": "https://github.com/Yoast/wp-test-utils.git", + "reference": "896f7640d86162ff7a0dc6ce59f8837f284521c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Yoast/wp-test-utils/zipball/896f7640d86162ff7a0dc6ce59f8837f284521c5", + "reference": "896f7640d86162ff7a0dc6ce59f8837f284521c5", + "shasum": "" + }, + "require": { + "brain/monkey": "^2.6.0", + "php": ">=5.6", + "yoast/phpunit-polyfills": "^1.0.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^0.5", + "php-parallel-lint/php-parallel-lint": "^1.3.0", + "yoast/yoastcs": "^2.1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Team Yoast", + "email": "support@yoast.com", + "homepage": "https://yoast.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Yoast/wp-test-utils/graphs/contributors" + } + ], + "description": "PHPUnit cross-version compatibility layer for testing plugins and themes build for WordPress", + "homepage": "https://github.com/Yoast/wp-test-utils/", + "keywords": [ + "brainmonkey", + "integration-testing", + "phpunit", + "unit-testing", + "wordpress" + ], + "support": { + "issues": "https://github.com/Yoast/wp-test-utils/issues", + "source": "https://github.com/Yoast/wp-test-utils" + }, + "time": "2021-06-21T03:45:02+00:00" } ], "aliases": [], diff --git a/patches/phpunit-mock-objects.patch b/patches/phpunit-mock-objects.patch new file mode 100644 index 00000000000..4f1b8c5465f --- /dev/null +++ b/patches/phpunit-mock-objects.patch @@ -0,0 +1,29 @@ +diff --git a/src/Framework/MockObject/Generator.php b/src/Framework/MockObject/Generator.php +index bfb899d..4f44e8d 100644 +--- a/src/Framework/MockObject/Generator.php ++++ b/src/Framework/MockObject/Generator.php +@@ -1193,13 +1193,13 @@ private function getMethodParameters(ReflectionMethod $method, $forCall = false) + } + + $typeDeclaration = (string) $parameter->getType() . ' '; +- } elseif ($parameter->isArray()) { ++ } elseif (PHP_VERSION_ID >= 70000 ? $parameter->getType() === 'array' : $parameter->isArray()) { + $typeDeclaration = 'array '; +- } elseif ($parameter->isCallable()) { ++ } elseif (PHP_VERSION_ID >= 70000 ? $parameter->getType() === 'callable' : $parameter->isCallable()) { + $typeDeclaration = 'callable '; + } else { + try { +- $class = $parameter->getClass(); ++ $class = PHP_VERSION_ID >= 70000 ? $parameter->getType() : $parameter->getClass(); + } catch (ReflectionException $e) { + throw new PHPUnit_Framework_MockObject_RuntimeException( + sprintf( +@@ -1214,7 +1214,7 @@ private function getMethodParameters(ReflectionMethod $method, $forCall = false) + } + + if ($class !== null) { +- $typeDeclaration = $class->getName() . ' '; ++ $typeDeclaration = (PHP_VERSION_ID >= 70000 ? $class : $class->getName()) . ' '; + } + } diff --git a/src/Infrastructure/Injector/SimpleInjector.php b/src/Infrastructure/Injector/SimpleInjector.php index 95f68b04946..2e0867be677 100644 --- a/src/Infrastructure/Injector/SimpleInjector.php +++ b/src/Infrastructure/Injector/SimpleInjector.php @@ -12,7 +12,6 @@ use AmpProject\AmpWP\Infrastructure\Instantiator; use Exception; use ReflectionClass; -use ReflectionNamedType; use ReflectionParameter; /** diff --git a/tests/php/src/Admin/AnalyticsOptionsSubmenuTest.php b/tests/php/src/Admin/AnalyticsOptionsSubmenuTest.php index 33b4791cb7d..607dec21770 100644 --- a/tests/php/src/Admin/AnalyticsOptionsSubmenuTest.php +++ b/tests/php/src/Admin/AnalyticsOptionsSubmenuTest.php @@ -14,8 +14,7 @@ use AmpProject\AmpWP\Admin\RESTPreloader; use AmpProject\AmpWP\DependencySupport; use AmpProject\AmpWP\LoadingError; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for AnalyticsOptionsSubmenu. @@ -23,9 +22,7 @@ * @group options-menu * @coversDefaultClass \AmpProject\AmpWP\Admin\AnalyticsOptionsSubmenu */ -class AnalyticsOptionsSubmenuTest extends WP_UnitTestCase { - - use AssertContainsCompatibility; +class AnalyticsOptionsSubmenuTest extends TestCase { /** * Instance of OptionsMenu class. @@ -89,7 +86,7 @@ public function test_link_is_added() { $this->options_menu_instance->add_menu_items(); $this->instance->add_submenu_link(); - $this->assertContains( 'Analytics', wp_list_pluck( $submenu[ $this->options_menu_instance->get_menu_slug() ], 0 ) ); + $this->assertStringContainsString( 'Analytics', wp_list_pluck( $submenu[ $this->options_menu_instance->get_menu_slug() ], 0 ) ); $submenu = $original_submenu; } diff --git a/tests/php/src/Admin/GoogleFontsTest.php b/tests/php/src/Admin/GoogleFontsTest.php index 60c9fce8b76..16dca101ae0 100644 --- a/tests/php/src/Admin/GoogleFontsTest.php +++ b/tests/php/src/Admin/GoogleFontsTest.php @@ -10,7 +10,7 @@ use AmpProject\AmpWP\Admin\GoogleFonts; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for GoogleFonts class. @@ -19,7 +19,7 @@ * * @coversDefaultClass \AmpProject\AmpWP\Admin\GoogleFonts */ -class GoogleFontsTest extends WP_UnitTestCase { +class GoogleFontsTest extends TestCase { /** * Test instance. diff --git a/tests/php/src/Admin/OnboardingWizardSubmenuPageTest.php b/tests/php/src/Admin/OnboardingWizardSubmenuPageTest.php index b1d7b5981cb..a520f2d6367 100644 --- a/tests/php/src/Admin/OnboardingWizardSubmenuPageTest.php +++ b/tests/php/src/Admin/OnboardingWizardSubmenuPageTest.php @@ -13,7 +13,6 @@ use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; use AmpProject\AmpWP\Tests\DependencyInjectedTestCase; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use AMP_Options_Manager; /** @@ -27,8 +26,6 @@ */ class OnboardingWizardSubmenuPageTest extends DependencyInjectedTestCase { - use AssertContainsCompatibility; - /** * Test instance. * @@ -103,7 +100,7 @@ public function test_render() { $this->onboarding_wizard_submenu_page->render(); - $this->assertStringContains( '
', ob_get_clean() ); + $this->assertStringContainsString( '
', ob_get_clean() ); } /** diff --git a/tests/php/src/Admin/OnboardingWizardSubmenuTest.php b/tests/php/src/Admin/OnboardingWizardSubmenuTest.php index 717507a9feb..6d2a1c6e300 100644 --- a/tests/php/src/Admin/OnboardingWizardSubmenuTest.php +++ b/tests/php/src/Admin/OnboardingWizardSubmenuTest.php @@ -11,7 +11,7 @@ use AmpProject\AmpWP\Infrastructure\Delayed; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for OnboardingWizardSubmenu class. @@ -22,7 +22,7 @@ * * @coversDefaultClass \AmpProject\AmpWP\Admin\OnboardingWizardSubmenu */ -class OnboardingWizardSubmenuTest extends WP_UnitTestCase { +class OnboardingWizardSubmenuTest extends TestCase { /** * Test instance. diff --git a/tests/php/src/Admin/OptionsMenuTest.php b/tests/php/src/Admin/OptionsMenuTest.php index d776b7f79b4..81fa6b8811a 100644 --- a/tests/php/src/Admin/OptionsMenuTest.php +++ b/tests/php/src/Admin/OptionsMenuTest.php @@ -16,8 +16,7 @@ use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; use AmpProject\AmpWP\LoadingError; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for OptionsMenu. @@ -25,9 +24,7 @@ * @group options-menu * @coversDefaultClass \AmpProject\AmpWP\Admin\OptionsMenu */ -class OptionsMenuTest extends WP_UnitTestCase { - - use AssertContainsCompatibility; +class OptionsMenuTest extends TestCase { /** * Instance of OptionsMenu @@ -124,6 +121,6 @@ public function test_render_screen_for_admin_user() { ob_start(); $this->instance->render_screen(); - $this->assertStringContains( '
', ob_get_clean() ); + $this->assertStringContainsString( '
', ob_get_clean() ); } } diff --git a/tests/php/src/Admin/PairedBrowsingTest.php b/tests/php/src/Admin/PairedBrowsingTest.php index 460648a9dbf..5a71a04c663 100644 --- a/tests/php/src/Admin/PairedBrowsingTest.php +++ b/tests/php/src/Admin/PairedBrowsingTest.php @@ -19,15 +19,12 @@ use AmpProject\AmpWP\QueryVar; use AmpProject\AmpWP\Services; use AmpProject\AmpWP\Tests\DependencyInjectedTestCase; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use AmpProject\DevMode; use WP_Admin_Bar; /** @coversDefaultClass \AmpProject\AmpWP\Admin\PairedBrowsing */ class PairedBrowsingTest extends DependencyInjectedTestCase { - use AssertContainsCompatibility; - /** @var PairedBrowsing */ private $instance; @@ -166,10 +163,10 @@ public function test_init_frontend_client() { $this->assertEquals( 1, did_action( 'amp_register_polyfills' ) ); $this->assertTrue( wp_script_is( 'amp-paired-browsing-client' ) ); $printed_scripts = get_echo( 'wp_print_scripts' ); - $this->assertStringContains( DevMode::DEV_MODE_ATTRIBUTE, $printed_scripts ); - $this->assertStringContains( 'ampPairedBrowsingClientData', $printed_scripts ); - $this->assertStringContains( 'isAmpDocument', $printed_scripts ); - $this->assertStringContains( 'amp-paired-browsing-client.js', $printed_scripts ); + $this->assertStringContainsString( DevMode::DEV_MODE_ATTRIBUTE, $printed_scripts ); + $this->assertStringContainsString( 'ampPairedBrowsingClientData', $printed_scripts ); + $this->assertStringContainsString( 'isAmpDocument', $printed_scripts ); + $this->assertStringContainsString( 'amp-paired-browsing-client.js', $printed_scripts ); // Check that init_app() was not called. $this->assertFalse( has_action( 'template_redirect', [ $this->instance, 'ensure_app_location' ] ) ); @@ -200,8 +197,8 @@ public function test_get_paired_browsing_url() { $post_id = self::factory()->post->create(); $this->go_to( amp_get_permalink( $post_id ) ); - $this->assertStringContains( PairedBrowsing::APP_QUERY_VAR . '=1', $this->instance->get_paired_browsing_url() ); - $this->assertStringNotContains( amp_get_slug() . '=1', $this->instance->get_paired_browsing_url() ); + $this->assertStringContainsString( PairedBrowsing::APP_QUERY_VAR . '=1', $this->instance->get_paired_browsing_url() ); + $this->assertStringNotContainsString( amp_get_slug() . '=1', $this->instance->get_paired_browsing_url() ); $this->assertEquals( $this->instance->get_paired_browsing_url(), $this->instance->get_paired_browsing_url( amp_get_current_url() ) @@ -243,9 +240,9 @@ public function test_filter_template_include_for_app_when_allowed() { load_template( $include_path ); $template = ob_get_clean(); - $this->assertStringContains( 'amp-paired-browsing-app.css', $template ); - $this->assertStringContains( 'amp-paired-browsing-app.js', $template ); - $this->assertStringContains( 'ampPairedBrowsingAppData', $template ); - $this->assertStringContains( 'ampPairedBrowsingQueryVar', $template ); + $this->assertStringContainsString( 'amp-paired-browsing-app.css', $template ); + $this->assertStringContainsString( 'amp-paired-browsing-app.js', $template ); + $this->assertStringContainsString( 'ampPairedBrowsingAppData', $template ); + $this->assertStringContainsString( 'ampPairedBrowsingQueryVar', $template ); } } diff --git a/tests/php/src/Admin/PluginActivationNoticeTest.php b/tests/php/src/Admin/PluginActivationNoticeTest.php index 34986e70957..895e99d1a3a 100644 --- a/tests/php/src/Admin/PluginActivationNoticeTest.php +++ b/tests/php/src/Admin/PluginActivationNoticeTest.php @@ -10,7 +10,7 @@ use AmpProject\AmpWP\Admin\PluginActivationNotice; use AmpProject\AmpWP\Option; use AMP_Options_Manager; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for PluginActivationNotice class. @@ -21,7 +21,7 @@ * * @coversDefaultClass \AmpProject\AmpWP\Admin\PluginActivationNotice */ -class PluginActivationNoticeTest extends WP_UnitTestCase { +class PluginActivationNoticeTest extends TestCase { /** * Test instance. @@ -52,10 +52,10 @@ public function test_register() { */ public function test_user_sees_notice() { set_current_screen( 'plugins' ); - $this->assertContains( 'class="amp-plugin-notice', get_echo( [ $this->plugin_activation_notice, 'render_notice' ] ) ); + $this->assertStringContainsString( 'class="amp-plugin-notice', get_echo( [ $this->plugin_activation_notice, 'render_notice' ] ) ); set_current_screen( 'toplevel_page_' . AMP_Options_Manager::OPTION_NAME ); - $this->assertNotContains( 'class="amp-plugin-notice', get_echo( [ $this->plugin_activation_notice, 'render_notice' ] ) ); + $this->assertStringNotContainsString( 'class="amp-plugin-notice', get_echo( [ $this->plugin_activation_notice, 'render_notice' ] ) ); } /** diff --git a/tests/php/src/Admin/PluginRowMetaTest.php b/tests/php/src/Admin/PluginRowMetaTest.php index 997cad859cd..14214c04243 100644 --- a/tests/php/src/Admin/PluginRowMetaTest.php +++ b/tests/php/src/Admin/PluginRowMetaTest.php @@ -11,14 +11,14 @@ use AmpProject\AmpWP\Infrastructure\Delayed; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for PluginRowMeta class. * * @coversDefaultClass \AmpProject\AmpWP\Admin\PluginRowMeta */ -class PluginRowMetaTest extends WP_UnitTestCase { +class PluginRowMetaTest extends TestCase { /** * Test instance. diff --git a/tests/php/src/Admin/PolyfillsTest.php b/tests/php/src/Admin/PolyfillsTest.php index 4706efc2f02..774a66a00db 100644 --- a/tests/php/src/Admin/PolyfillsTest.php +++ b/tests/php/src/Admin/PolyfillsTest.php @@ -15,7 +15,7 @@ use AmpProject\AmpWP\Infrastructure\Service; use WP_Scripts; use WP_Styles; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for Polyfills class. @@ -24,7 +24,7 @@ * * @coversDefaultClass \AmpProject\AmpWP\Admin\Polyfills */ -class PolyfillsTest extends WP_UnitTestCase { +class PolyfillsTest extends TestCase { /** * Test instance. @@ -77,11 +77,11 @@ public function test_registration() { // These should pass in WP < 5.6. $this->assertTrue( wp_script_is( 'lodash', 'registered' ) ); - $this->assertContains( '_.noConflict();', $wp_scripts->print_inline_script( 'lodash', 'after', false ) ); + $this->assertStringContainsString( '_.noConflict();', $wp_scripts->print_inline_script( 'lodash', 'after', false ) ); $this->assertTrue( wp_script_is( 'wp-api-fetch', 'registered' ) ); - $this->assertContains( 'createRootURLMiddleware', $wp_scripts->print_inline_script( 'wp-api-fetch', 'after', false ) ); - $this->assertContains( 'createNonceMiddleware', $wp_scripts->print_inline_script( 'wp-api-fetch', 'after', false ) ); + $this->assertStringContainsString( 'createRootURLMiddleware', $wp_scripts->print_inline_script( 'wp-api-fetch', 'after', false ) ); + $this->assertStringContainsString( 'createNonceMiddleware', $wp_scripts->print_inline_script( 'wp-api-fetch', 'after', false ) ); $this->assertTrue( wp_script_is( 'wp-hooks', 'registered' ) ); $this->assertTrue( wp_script_is( 'wp-i18n', 'registered' ) ); diff --git a/tests/php/src/Admin/RESTPreloaderTest.php b/tests/php/src/Admin/RESTPreloaderTest.php index 93fe200707a..dfe309fa411 100644 --- a/tests/php/src/Admin/RESTPreloaderTest.php +++ b/tests/php/src/Admin/RESTPreloaderTest.php @@ -8,7 +8,7 @@ namespace AmpProject\AmpWP\Tests\Admin; use AmpProject\AmpWP\Admin\RESTPreloader; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for RESTPreloader class. @@ -17,7 +17,7 @@ * * @coversDefaultClass \AmpProject\AmpWP\Admin\RESTPreloader */ -class RESTPreloaderTest extends WP_UnitTestCase { +class RESTPreloaderTest extends TestCase { /** * Test instance. diff --git a/tests/php/src/Admin/ReaderThemesTest.php b/tests/php/src/Admin/ReaderThemesTest.php index 291089ff438..ac0f35be9d7 100644 --- a/tests/php/src/Admin/ReaderThemesTest.php +++ b/tests/php/src/Admin/ReaderThemesTest.php @@ -13,10 +13,9 @@ use AmpProject\AmpWP\Admin\ReaderThemes; use AmpProject\AmpWP\ExtraThemeAndPluginHeaders; use AmpProject\AmpWP\Option; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use AmpProject\AmpWP\Tests\Helpers\LoadsCoreThemes; use AmpProject\AmpWP\Tests\Helpers\ThemesApiRequestMocking; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; use Closure; use WP_Error; @@ -27,9 +26,9 @@ * * @coversDefaultClass \AmpProject\AmpWP\Admin\ReaderThemes */ -class ReaderThemesTest extends WP_UnitTestCase { +class ReaderThemesTest extends TestCase { - use AssertContainsCompatibility, ThemesApiRequestMocking, LoadsCoreThemes; + use ThemesApiRequestMocking, LoadsCoreThemes; /** * Test instance. @@ -102,9 +101,9 @@ public function test_get_themes() { $themes = ( new ReaderThemes() )->get_themes(); $available_theme_slugs = wp_list_pluck( $themes, 'slug' ); - $this->assertContains( 'child-of-core', $available_theme_slugs ); - $this->assertNotContains( 'custom', $available_theme_slugs ); - $this->assertNotContains( 'with-legacy', $available_theme_slugs ); + $this->assertStringContainsString( 'child-of-core', $available_theme_slugs ); + $this->assertStringNotContainsString( 'custom', $available_theme_slugs ); + $this->assertStringNotContainsString( 'with-legacy', $available_theme_slugs ); } /** @@ -186,8 +185,8 @@ public function test_themes_api_wp_error() { $error->get_error_message() ); if ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) { - $this->assertStringContains( 'Test message', $error->get_error_message() ); - $this->assertStringContains( 'amp_test_error', $error->get_error_message() ); + $this->assertStringContainsString( 'Test message', $error->get_error_message() ); + $this->assertStringContainsString( 'amp_test_error', $error->get_error_message() ); } } diff --git a/tests/php/src/Admin/ValidationCountsTest.php b/tests/php/src/Admin/ValidationCountsTest.php index ea7f78dc1d9..8610346f759 100644 --- a/tests/php/src/Admin/ValidationCountsTest.php +++ b/tests/php/src/Admin/ValidationCountsTest.php @@ -19,14 +19,14 @@ use AmpProject\AmpWP\Infrastructure\Service; use AmpProject\AmpWP\Option; use AmpProject\AmpWP\Services; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for ValidationCounts class. * * @coversDefaultClass \AmpProject\AmpWP\Admin\ValidationCounts */ -class ValidationCountsTest extends WP_UnitTestCase { +class ValidationCountsTest extends TestCase { /** * Test instance. diff --git a/tests/php/src/AmpSlugCustomizationWatcherTest.php b/tests/php/src/AmpSlugCustomizationWatcherTest.php index b8858711ecf..576de4af9ca 100644 --- a/tests/php/src/AmpSlugCustomizationWatcherTest.php +++ b/tests/php/src/AmpSlugCustomizationWatcherTest.php @@ -5,13 +5,10 @@ use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; use AmpProject\AmpWP\AmpSlugCustomizationWatcher; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** @coversDefaultClass \AmpProject\AmpWP\AmpSlugCustomizationWatcher */ -final class AmpSlugCustomizationWatcherTest extends WP_UnitTestCase { - - use AssertContainsCompatibility; +final class AmpSlugCustomizationWatcherTest extends TestCase { /** @var AmpSlugCustomizationWatcher */ private $instance; diff --git a/tests/php/src/AmpWpPluginTest.php b/tests/php/src/AmpWpPluginTest.php index e56a3a2bd43..07ddde2b616 100644 --- a/tests/php/src/AmpWpPluginTest.php +++ b/tests/php/src/AmpWpPluginTest.php @@ -6,9 +6,9 @@ use AmpProject\AmpWP\Infrastructure\Injector; use AmpProject\AmpWP\PluginRegistry; use AmpProject\AmpWP\Tests\Fixture\DummyService; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; -final class AmpWpPluginTest extends WP_UnitTestCase { +final class AmpWpPluginTest extends TestCase { public function test_it_has_filtering_disabled_by_default() { $plugin = new AmpWpPlugin(); diff --git a/tests/php/src/BackgroundTask/BackgroundTaskDeactivatorTest.php b/tests/php/src/BackgroundTask/BackgroundTaskDeactivatorTest.php index 3555d378de2..31e00067d80 100644 --- a/tests/php/src/BackgroundTask/BackgroundTaskDeactivatorTest.php +++ b/tests/php/src/BackgroundTask/BackgroundTaskDeactivatorTest.php @@ -9,15 +9,14 @@ use AmpProject\AmpWP\Infrastructure\Deactivateable; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * @coversDefaultClass \AmpProject\AmpWP\BackgroundTask\BackgroundTaskDeactivator */ -final class BackgroundTaskDeactivatorTest extends WP_UnitTestCase { - use AssertContainsCompatibility, PrivateAccess; +final class BackgroundTaskDeactivatorTest extends TestCase { + use PrivateAccess; /** * BackgroundTaskDeactivator instance. @@ -127,7 +126,7 @@ public function test_network_deactivate_warning() { $new_actions = $this->test_instance->add_warning_sign_to_network_deactivate_action( $actions ); $this->assertTrue( wp_style_is( 'amp-icons' ) ); - $this->assertContains( '', $new_actions['deactivate'] ); + $this->assertStringContainsString( '', $new_actions['deactivate'] ); remove_filter( 'wp_is_large_network', '__return_true' ); } diff --git a/tests/php/src/BackgroundTask/MonitorCssTransientCachingTest.php b/tests/php/src/BackgroundTask/MonitorCssTransientCachingTest.php index e8a94245a32..fed00348fe2 100644 --- a/tests/php/src/BackgroundTask/MonitorCssTransientCachingTest.php +++ b/tests/php/src/BackgroundTask/MonitorCssTransientCachingTest.php @@ -10,10 +10,10 @@ use AmpProject\AmpWP\BackgroundTask\MonitorCssTransientCaching; use AmpProject\AmpWP\Option; use DateTime; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** @coversDefaultClass \AmpProject\AmpWP\BackgroundTask\MonitorCssTransientCaching */ -class MonitorCssTransientCachingTest extends WP_UnitTestCase { +class MonitorCssTransientCachingTest extends TestCase { /** * Whether external object cache is being used. @@ -57,7 +57,7 @@ public function test_event_gets_scheduled_and_unscheduled() { $timestamp = wp_next_scheduled( MonitorCssTransientCaching::EVENT_NAME ); $this->assertNotFalse( $timestamp ); - $this->assertInternalType( 'int', $timestamp ); + $this->assertIsInt( $timestamp ); $this->assertGreaterThan( 0, $timestamp ); } diff --git a/tests/php/src/DependencyInjectedTestCase.php b/tests/php/src/DependencyInjectedTestCase.php index cadf0a5f4ea..450a86a0f77 100644 --- a/tests/php/src/DependencyInjectedTestCase.php +++ b/tests/php/src/DependencyInjectedTestCase.php @@ -7,9 +7,9 @@ use AmpProject\AmpWP\Infrastructure\ServiceContainer; use AmpProject\AmpWP\Services; use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; -abstract class DependencyInjectedTestCase extends WP_UnitTestCase { +abstract class DependencyInjectedTestCase extends TestCase { use PrivateAccess; diff --git a/tests/php/src/DependencySupportTest.php b/tests/php/src/DependencySupportTest.php index d25d15392c2..fa42e8d5e57 100644 --- a/tests/php/src/DependencySupportTest.php +++ b/tests/php/src/DependencySupportTest.php @@ -4,10 +4,10 @@ use AmpProject\AmpWP\DependencySupport; use AmpProject\AmpWP\Infrastructure\Service; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** @coversDefaultClass \AmpProject\AmpWP\DependencySupport */ -class DependencySupportTest extends WP_UnitTestCase { +class DependencySupportTest extends TestCase { /** @var DependencySupport */ private $instance; diff --git a/tests/php/src/DevTools/BlockSourcesTest.php b/tests/php/src/DevTools/BlockSourcesTest.php index beb0a7af13c..ed2b80521b5 100644 --- a/tests/php/src/DevTools/BlockSourcesTest.php +++ b/tests/php/src/DevTools/BlockSourcesTest.php @@ -16,7 +16,7 @@ use AmpProject\AmpWP\PluginRegistry; use AmpProject\AmpWP\Tests\Helpers\MockPluginEnvironment; use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; -use WP_UnitTestCase; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for the BlockSources class. @@ -25,7 +25,7 @@ * * @coversDefaultClass \AmpProject\AmpWP\DevTools\BlockSources */ -class BlockSourcesTest extends WP_UnitTestCase { +class BlockSourcesTest extends TestCase { use PrivateAccess; diff --git a/tests/php/src/DevTools/ErrorPageTest.php b/tests/php/src/DevTools/ErrorPageTest.php index 2d9045b3499..e622c334dcb 100644 --- a/tests/php/src/DevTools/ErrorPageTest.php +++ b/tests/php/src/DevTools/ErrorPageTest.php @@ -4,11 +4,9 @@ use AmpProject\AmpWP\DevTools\ErrorPage; use AmpProject\AmpWP\Tests\DependencyInjectedTestCase; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use RuntimeException; final class ErrorPageTest extends DependencyInjectedTestCase { - use AssertContainsCompatibility; public function test_error_page_output() { // Set up temporary capture of error log to test error log output. @@ -27,7 +25,7 @@ public function test_error_page_output() { ->render(); // Verify that error log was properly populated. - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/^\[[^\]]*\] Error Page Message - FAILURE \(42\) \[RuntimeException\].*/', stream_get_contents( $capture ) ); @@ -36,17 +34,17 @@ public function test_error_page_output() { ini_set( 'error_log', $backup ); // phpcs:ignore WordPress.PHP.IniSet.Risky // Test HTML output. - $this->assertStringContains( 'Error Page Title', $output ); - $this->assertStringContains( '

Error Page Title

', $output ); - $this->assertStringContains( '

Error Page Message

', $output ); - $this->assertStringContains( 'FAILURE (42) [RuntimeException]', $output ); - $this->assertStringContains( '', $output ); - $this->assertStringContains( 'assertStringContains( '', $output ); - $this->assertStringContains( '', $content ); - $this->assertStringContains( 'Has script? Nope!', $content ); - $this->assertStringContains( '', $content ); + $this->assertMatchesRegularExpression( '/\s*/', $content ); + $this->assertStringContainsString( '', $content ); + $this->assertStringContainsString( 'Has script? Nope!', $content ); + $this->assertStringContainsString( '', $content ); } } diff --git a/tests/php/test-amp-soundcloud-embed-handler.php b/tests/php/test-amp-soundcloud-embed-handler.php index 92bbd956537..a47abc6e132 100644 --- a/tests/php/test-amp-soundcloud-embed-handler.php +++ b/tests/php/test-amp-soundcloud-embed-handler.php @@ -6,13 +6,14 @@ */ use AmpProject\AmpWP\Tests\Helpers\WithoutBlockPreRendering; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Class AMP_SoundCloud_Embed_Handler_Test * * @covers AMP_SoundCloud_Embed_Handler */ -class AMP_SoundCloud_Embed_Handler_Test extends WP_UnitTestCase { +class AMP_SoundCloud_Embed_Handler_Test extends TestCase { use WithoutBlockPreRendering { setUp as public prevent_block_pre_render; diff --git a/tests/php/test-amp-style-sanitizer.php b/tests/php/test-amp-style-sanitizer.php index 3cb211e6d40..830a1e246af 100644 --- a/tests/php/test-amp-style-sanitizer.php +++ b/tests/php/test-amp-style-sanitizer.php @@ -11,19 +11,18 @@ use AmpProject\AmpWP\Option; use AmpProject\AmpWP\RemoteRequest\CachedResponse; use AmpProject\AmpWP\RemoteRequest\CachedRemoteGetRequest; -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use AmpProject\AmpWP\Tests\Helpers\LoadsCoreThemes; use AmpProject\AmpWP\Tests\Helpers\MarkupComparison; use AmpProject\Dom\Document; use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; use AmpProject\Exception\FailedToGetFromRemoteUrl; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Test AMP_Style_Sanitizer. */ -class AMP_Style_Sanitizer_Test extends WP_UnitTestCase { +class AMP_Style_Sanitizer_Test extends TestCase { - use AssertContainsCompatibility; use MarkupComparison; use PrivateAccess; use LoadsCoreThemes; @@ -912,15 +911,15 @@ static function( $preempt, $request, $url ) { } if ( false === strpos( $expected_stylesheet, '{' ) ) { - $this->assertStringContains( $expected_stylesheet, $actual_stylesheets[ $i ] ); + $this->assertStringContainsString( $expected_stylesheet, $actual_stylesheets[ $i ] ); } else { $this->assertEquals( $expected_stylesheet, $actual_stylesheets[ $i ] ); } - $this->assertStringContains( $expected_stylesheet, $sanitized_html ); + $this->assertStringContainsString( $expected_stylesheet, $sanitized_html ); } if ( $actual_stylesheets ) { - $this->assertStringContains( "\n\n/*# sourceURL=amp-custom.css */", $sanitized_html ); + $this->assertStringContainsString( "\n\n/*# sourceURL=amp-custom.css */", $sanitized_html ); } } @@ -1554,11 +1553,11 @@ public function test_font_data_url_handling() { $this->assertEquals( [], $error_codes ); $actual_stylesheets = array_values( $sanitizer->get_stylesheets() ); $this->assertCount( 1, $actual_stylesheets ); - $this->assertStringContains( 'dashicons.woff") format("woff")', $actual_stylesheets[0] ); - $this->assertStringNotContains( 'data:application/font-woff;', $actual_stylesheets[0] ); - $this->assertStringContains( '.dashicons{', $actual_stylesheets[0] ); - $this->assertStringContains( '.dashicons-admin-appearance:before{', $actual_stylesheets[0] ); - $this->assertStringNotContains( '.dashicons-format-chat:before', $actual_stylesheets[0] ); + $this->assertStringContainsString( 'dashicons.woff") format("woff")', $actual_stylesheets[0] ); + $this->assertStringNotContainsString( 'data:application/font-woff;', $actual_stylesheets[0] ); + $this->assertStringContainsString( '.dashicons{', $actual_stylesheets[0] ); + $this->assertStringContainsString( '.dashicons-admin-appearance:before{', $actual_stylesheets[0] ); + $this->assertStringNotContainsString( '.dashicons-format-chat:before', $actual_stylesheets[0] ); } /** @@ -1596,26 +1595,26 @@ public function test_font_data_url_handling_without_file_sources() { $this->assertCount( 3, $actual_stylesheets ); // Check font included in theme. - $this->assertStringContains( '@font-face{font-family:"NonBreakingSpaceOverride";', $actual_stylesheets[0] ); - $this->assertStringContains( 'format("woff2")', $actual_stylesheets[0] ); - $this->assertStringContains( 'format("woff")', $actual_stylesheets[0] ); - $this->assertStringNotContains( 'data:', $actual_stylesheets[0] ); - $this->assertStringContains( 'fonts/NonBreakingSpaceOverride.woff2', $actual_stylesheets[0] ); - $this->assertStringContains( 'fonts/NonBreakingSpaceOverride.woff', $actual_stylesheets[0] ); - $this->assertStringContains( 'font-display:swap', $actual_stylesheets[0] ); + $this->assertStringContainsString( '@font-face{font-family:"NonBreakingSpaceOverride";', $actual_stylesheets[0] ); + $this->assertStringContainsString( 'format("woff2")', $actual_stylesheets[0] ); + $this->assertStringContainsString( 'format("woff")', $actual_stylesheets[0] ); + $this->assertStringNotContainsString( 'data:', $actual_stylesheets[0] ); + $this->assertStringContainsString( 'fonts/NonBreakingSpaceOverride.woff2', $actual_stylesheets[0] ); + $this->assertStringContainsString( 'fonts/NonBreakingSpaceOverride.woff', $actual_stylesheets[0] ); + $this->assertStringContainsString( 'font-display:swap', $actual_stylesheets[0] ); // Check font not included in theme, but included in plugin. - $this->assertStringContains( '@font-face{font-family:"Genericons";', $actual_stylesheets[1] ); - $this->assertStringContains( 'format("woff")', $actual_stylesheets[1] ); - $this->assertStringNotContains( 'data:', $actual_stylesheets[1] ); - $this->assertStringContains( 'assets/fonts/genericons.woff', $actual_stylesheets[1] ); - $this->assertStringContains( 'font-display:swap', $actual_stylesheets[1] ); + $this->assertStringContainsString( '@font-face{font-family:"Genericons";', $actual_stylesheets[1] ); + $this->assertStringContainsString( 'format("woff")', $actual_stylesheets[1] ); + $this->assertStringNotContainsString( 'data:', $actual_stylesheets[1] ); + $this->assertStringContainsString( 'assets/fonts/genericons.woff', $actual_stylesheets[1] ); + $this->assertStringContainsString( 'font-display:swap', $actual_stylesheets[1] ); // Check font not included anywhere, so must remain inline. - $this->assertStringContains( '@font-face{font-family:"Custom";', $actual_stylesheets[2] ); - $this->assertStringContains( 'url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAA")', $actual_stylesheets[2] ); - $this->assertStringContains( 'format("woff")', $actual_stylesheets[2] ); - $this->assertStringNotContains( 'font-display:swap', $actual_stylesheets[2] ); + $this->assertStringContainsString( '@font-face{font-family:"Custom";', $actual_stylesheets[2] ); + $this->assertStringContainsString( 'url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAA")', $actual_stylesheets[2] ); + $this->assertStringContainsString( 'format("woff")', $actual_stylesheets[2] ); + $this->assertStringNotContainsString( 'font-display:swap', $actual_stylesheets[2] ); } /** @@ -1785,8 +1784,8 @@ public function test_relative_background_url_handling() { $this->assertCount( 1, $actual_stylesheets ); $stylesheet = $actual_stylesheets[0]; - $this->assertStringNotContains( '../images/spinner', $stylesheet ); - $this->assertStringContains( sprintf( '.spinner{background-image:url("%s")', admin_url( 'images/spinner-2x.gif' ) ), $stylesheet ); + $this->assertStringNotContainsString( '../images/spinner', $stylesheet ); + $this->assertStringContainsString( sprintf( '.spinner{background-image:url("%s")', admin_url( 'images/spinner-2x.gif' ) ), $stylesheet ); } /** @@ -1849,7 +1848,7 @@ public function test_external_stylesheet_handling( $href, $content_type, $respon add_filter( 'pre_http_request', function( $preempt, $request, $url ) use ( $href, &$request_count, $content_type, $response_body ) { - $this->assertRegExp( '#^https?://#', $url ); + $this->assertMatchesRegularExpression( '#^https?://#', $url ); if ( set_url_scheme( $url, 'https' ) === set_url_scheme( $href, 'https' ) ) { $request_count++; $preempt = [ @@ -1923,7 +1922,7 @@ public function test_external_stylesheet_cache_control() { add_filter( 'pre_http_request', function( $preempt, $request, $url ) use ( $href, &$request_count, $response_body, $headers, $status_code ) { - $this->assertRegExp( '#^https?://#', $url ); + $this->assertMatchesRegularExpression( '#^https?://#', $url ); if ( set_url_scheme( $url, 'https' ) === set_url_scheme( $href, 'https' ) ) { $request_count++; $preempt = [ @@ -2016,7 +2015,7 @@ public function get_external_stylesheet_data() { ], 'expected_styles' => [ 'body{color:#fff}' ], 'expected_errors' => [], - 'cached_data' => new CachedResponse( + 'expected_cached_response' => new CachedResponse( 'body { color: #fff }', [ 'cache-control' => 'max-age=1441', @@ -2037,7 +2036,7 @@ public function get_external_stylesheet_data() { ], 'expected_styles' => [], 'expected_errors' => [ AMP_Style_Sanitizer::STYLESHEET_FETCH_ERROR ], - 'cached_data' => new CachedResponse( + 'expected_cached_response' => new CachedResponse( FailedToGetFromRemoteUrl::withHttpStatus( 'https://www.example.com/not-found/styles.css', 404 )->getMessage(), [], 404, @@ -2065,7 +2064,7 @@ public function test_external_stylesheet( $style_url, $http_response, $expected_ add_filter( 'pre_http_request', function( $preempt, $request, $url ) use ( $style_url, $http_response, &$request_count ) { - $this->assertRegExp( '#^https?://#', $url ); + $this->assertMatchesRegularExpression( '#^https?://#', $url ); if ( set_url_scheme( $url, 'https' ) === set_url_scheme( $style_url, 'https' ) ) { $request_count++; $preempt = [ @@ -2341,7 +2340,7 @@ public function test_get_validated_url_file_path( $source, $expected, $error_cod $this->assertInstanceOf( 'WP_Error', $actual ); $this->assertEquals( $error_code, $actual->get_error_code() ); } else { - $this->assertInternalType( 'string', $actual ); + $this->assertIsString( $actual ); $this->assertEquals( $expected, $actual ); } } @@ -2401,7 +2400,7 @@ public function test_remove_spaces_from_url_values( $source, $expected ) { $stylesheets = array_values( $sanitizer->get_stylesheets() ); - $this->assertStringContains( $expected, $stylesheets[0] ); + $this->assertStringContainsString( $expected, $stylesheets[0] ); } /** @@ -2533,7 +2532,7 @@ static function ( WP_UnitTestCase $test, $stylesheet ) { preg_quote( '.wp-core-ui .button', '/' ), preg_quote( 'div::after{content:"After login"}', '/' ), ]; - $test->assertRegExp( + $test->assertMatchesRegularExpression( '/.*' . implode( '.*', $expected_order ) . '/s', $stylesheet ); @@ -2569,7 +2568,7 @@ static function ( WP_UnitTestCase $test, $stylesheet ) { $previous = -1; foreach ( $expected_order as $i => $expected ) { - $test->assertStringContains( $expected, $stylesheet, "Did not see $expected at position $i." ); + $test->assertStringContainsString( $expected, $stylesheet, "Did not see $expected at position $i." ); $position = strpos( $stylesheet, $expected ); $test->assertGreaterThan( $previous, $position, "Expected $expected to be after previous (at position $i)." ); $previous = $position; @@ -2603,7 +2602,7 @@ static function ( WP_UnitTestCase $test, $stylesheet ) { 'remote-finally-does-not-exist.css', ]; foreach ( $expected_absent as $expected ) { - $test->assertStringNotContains( $expected, $stylesheet, "Expected to not see $expected." ); + $test->assertStringNotContainsString( $expected, $stylesheet, "Expected to not see $expected." ); } $expected_order = [ @@ -2615,7 +2614,7 @@ static function ( WP_UnitTestCase $test, $stylesheet ) { $previous = -1; foreach ( $expected_order as $i => $expected ) { - $test->assertStringContains( $expected, $stylesheet, "Did not see $expected at position $i." ); + $test->assertStringContainsString( $expected, $stylesheet, "Did not see $expected at position $i." ); $position = strpos( $stylesheet, $expected ); $test->assertGreaterThan( $previous, $position, "Expected $expected to be after previous (at position $i)." ); $previous = $position; @@ -2637,7 +2636,7 @@ static function( $requested_url ) { return null; }, static function ( WP_UnitTestCase $test, $stylesheet ) { - $test->assertRegExp( + $test->assertMatchesRegularExpression( '/.*' . preg_quote( '.wp-core-ui .button', '/' ) . '.*' . preg_quote( 'body{color:#123456}', '/' ) . '.*' . preg_quote( 'div::after{content:"After import-buttons"}', '/' ) . '/s', $stylesheet ); @@ -2655,7 +2654,7 @@ static function( $requested_url ) { return null; }, static function ( WP_UnitTestCase $test, $stylesheet ) { - $test->assertRegExp( + $test->assertMatchesRegularExpression( '/.*' . preg_quote( '.wp-core-ui .button', '/' ) . '.*' . preg_quote( 'body{color:#123456}', '/' ) . '.*' . preg_quote( 'div::after{content:"After import-buttons2"}', '/' ) . '/s', $stylesheet ); @@ -2676,7 +2675,7 @@ static function( $requested_url ) { return null; }, static function ( WP_UnitTestCase $test, $stylesheet ) { - $test->assertRegExp( + $test->assertMatchesRegularExpression( '/.*' . preg_quote( 'div::before{content:"HELLO NESTED"}', '/' ) . '.*' . preg_quote( 'body{color:#123456}', '/' ) . '.*' . preg_quote( 'div::after{content:"After import-buttons2"}', '/' ) . '/s', $stylesheet ); @@ -2819,8 +2818,8 @@ public function test_unicode_stylesheet() { $original_html = trim( ob_get_clean() ); $sanitized_html = AMP_Theme_Support::prepare_response( $original_html ); - $this->assertStringContains( ".dashicons-admin-customizer:before{content:\"\xEF\x95\x80\"}", $sanitized_html ); - $this->assertStringContains( 'span::after{content:"⚡️"}', $sanitized_html ); + $this->assertStringContainsString( ".dashicons-admin-customizer:before{content:\"\xEF\x95\x80\"}", $sanitized_html ); + $this->assertStringContainsString( 'span::after{content:"⚡️"}', $sanitized_html ); } /** @@ -2949,15 +2948,15 @@ function( $original_dom, $original_source, $amphtml_dom, $amphtml_source ) { */ $this->assertInstanceOf( 'DOMElement', $original_dom->getElementById( 'wpadminbar' ), 'Expected admin bar element to be present originally.' ); $this->assertInstanceOf( 'DOMElement', $original_dom->getElementById( 'admin-bar-css' ), 'Expected admin bar CSS to be present originally.' ); - $this->assertStringContains( 'admin-bar', $original_dom->body->getAttribute( 'class' ) ); - $this->assertStringContains( 'earlyprintstyle', $original_source, 'Expected early print style to not be present.' ); - - $this->assertStringContains( '.wp-block-audio figcaption', $amphtml_source, 'Expected block-library/style.css' ); - $this->assertStringContains( '[class^="wp-block-"]:not(.wp-block-gallery) figcaption', $amphtml_source, 'Expected twentyten/blocks.css' ); - $this->assertStringContains( 'amp-img img', $amphtml_source, 'Expected amp-default.css' ); - $this->assertStringContains( 'ab-empty-item', $amphtml_source, 'Expected admin-bar.css to still be present.' ); - $this->assertStringNotContains( 'earlyprintstyle', $amphtml_source, 'Expected early print style to not be present.' ); - $this->assertStringContains( 'admin-bar', $amphtml_dom->body->getAttribute( 'class' ) ); + $this->assertStringContainsString( 'admin-bar', $original_dom->body->getAttribute( 'class' ) ); + $this->assertStringContainsString( 'earlyprintstyle', $original_source, 'Expected early print style to not be present.' ); + + $this->assertStringContainsString( '.wp-block-audio figcaption', $amphtml_source, 'Expected block-library/style.css' ); + $this->assertStringContainsString( '[class^="wp-block-"]:not(.wp-block-gallery) figcaption', $amphtml_source, 'Expected twentyten/blocks.css' ); + $this->assertStringContainsString( 'amp-img img', $amphtml_source, 'Expected amp-default.css' ); + $this->assertStringContainsString( 'ab-empty-item', $amphtml_source, 'Expected admin-bar.css to still be present.' ); + $this->assertStringNotContainsString( 'earlyprintstyle', $amphtml_source, 'Expected early print style to not be present.' ); + $this->assertStringContainsString( 'admin-bar', $amphtml_dom->body->getAttribute( 'class' ) ); $this->assertInstanceOf( 'DOMElement', $amphtml_dom->getElementById( 'wpadminbar' ) ); }, ], diff --git a/tests/php/test-amp-tag-and-attribute-sanitizer-private-methods.php b/tests/php/test-amp-tag-and-attribute-sanitizer-private-methods.php index 37ec499e027..e5ec5761bee 100644 --- a/tests/php/test-amp-tag-and-attribute-sanitizer-private-methods.php +++ b/tests/php/test-amp-tag-and-attribute-sanitizer-private-methods.php @@ -4,8 +4,9 @@ // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; +use Yoast\WPTestUtils\WPIntegration\TestCase; -class AMP_Tag_And_Attribute_Sanitizer_Attr_Spec_Rules_Test extends WP_UnitTestCase { +class AMP_Tag_And_Attribute_Sanitizer_Attr_Spec_Rules_Test extends TestCase { use PrivateAccess; diff --git a/tests/php/test-amp-tumblr-embed-handler.php b/tests/php/test-amp-tumblr-embed-handler.php index d0c4fb13e1c..028d1fdb14b 100644 --- a/tests/php/test-amp-tumblr-embed-handler.php +++ b/tests/php/test-amp-tumblr-embed-handler.php @@ -6,13 +6,14 @@ */ use AmpProject\AmpWP\Tests\Helpers\MarkupComparison; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for Tumblr embeds. * * @coversDefaultClass \AMP_Tumblr_Embed_Handler */ -class AMP_Tumblr_Embed_Handler_Test extends WP_UnitTestCase { +class AMP_Tumblr_Embed_Handler_Test extends TestCase { use MarkupComparison; diff --git a/tests/php/test-amp-twitter-embed-handler.php b/tests/php/test-amp-twitter-embed-handler.php index 3bbfce65cd8..80350b1e4bf 100644 --- a/tests/php/test-amp-twitter-embed-handler.php +++ b/tests/php/test-amp-twitter-embed-handler.php @@ -6,13 +6,14 @@ */ use AmpProject\AmpWP\Tests\Helpers\WithoutBlockPreRendering; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Class AMP_Twitter_Embed_Handler_Test * * @covers AMP_Twitter_Embed_Handler */ -class AMP_Twitter_Embed_Handler_Test extends WP_UnitTestCase { +class AMP_Twitter_Embed_Handler_Test extends TestCase { use WithoutBlockPreRendering { setUp as public prevent_block_pre_render; diff --git a/tests/php/test-amp-video-sanitizer.php b/tests/php/test-amp-video-sanitizer.php index ea5fd641a33..3160fe31bb8 100644 --- a/tests/php/test-amp-video-sanitizer.php +++ b/tests/php/test-amp-video-sanitizer.php @@ -6,6 +6,7 @@ */ use AmpProject\AmpWP\Tests\Helpers\MarkupComparison; +use Yoast\WPTestUtils\WPIntegration\TestCase; // phpcs:disable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned @@ -14,7 +15,7 @@ * * @covers AMP_Video_Sanitizer */ -class AMP_Video_Converter_Test extends WP_UnitTestCase { +class AMP_Video_Converter_Test extends TestCase { use MarkupComparison; diff --git a/tests/php/test-amp-vimeo-embed-handler.php b/tests/php/test-amp-vimeo-embed-handler.php index 5b10a0376ab..110c340612a 100644 --- a/tests/php/test-amp-vimeo-embed-handler.php +++ b/tests/php/test-amp-vimeo-embed-handler.php @@ -6,13 +6,14 @@ */ use AmpProject\AmpWP\Tests\Helpers\WithoutBlockPreRendering; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Class AMP_Vimeo_Embed_Handler_Test * * @covers AMP_Vimeo_Embed_Handler */ -class AMP_Vimeo_Embed_Handler_Test extends WP_UnitTestCase { +class AMP_Vimeo_Embed_Handler_Test extends TestCase { use WithoutBlockPreRendering; diff --git a/tests/php/test-amp.php b/tests/php/test-amp.php index c4fd0de38c6..db4e976f388 100644 --- a/tests/php/test-amp.php +++ b/tests/php/test-amp.php @@ -6,11 +6,12 @@ */ use AmpProject\AmpWP\Option; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for amp.php. */ -class Test_AMP extends WP_UnitTestCase { +class Test_AMP extends TestCase { /** * Set up. diff --git a/tests/php/test-class-amp-accessibility-sanitizer.php b/tests/php/test-class-amp-accessibility-sanitizer.php index 651b84cf19b..e4e8b808fe1 100644 --- a/tests/php/test-class-amp-accessibility-sanitizer.php +++ b/tests/php/test-class-amp-accessibility-sanitizer.php @@ -6,11 +6,12 @@ */ use AmpProject\AmpWP\Tests\Helpers\MarkupComparison; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests the accessibility sanitizer class. */ -class AMP_Accessibility_Sanitizer_Test extends WP_UnitTestCase { +class AMP_Accessibility_Sanitizer_Test extends TestCase { use MarkupComparison; diff --git a/tests/php/test-class-amp-admin-pointer.php b/tests/php/test-class-amp-admin-pointer.php index b7c3cc1515b..e1179d9f621 100644 --- a/tests/php/test-class-amp-admin-pointer.php +++ b/tests/php/test-class-amp-admin-pointer.php @@ -5,13 +5,15 @@ * @package AMP */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for AMP_Admin_Pointers class. * * @covers AMP_Admin_Pointers * @since 1.0 */ -class Test_AMP_Admin_Pointers extends WP_UnitTestCase { +class Test_AMP_Admin_Pointers extends TestCase { /** * The meta key of the dismissed pointers. diff --git a/tests/php/test-class-amp-base-sanitizer.php b/tests/php/test-class-amp-base-sanitizer.php index 4f29395d57a..30bbb67e9b1 100644 --- a/tests/php/test-class-amp-base-sanitizer.php +++ b/tests/php/test-class-amp-base-sanitizer.php @@ -7,13 +7,14 @@ use AmpProject\Dom\Document; use AmpProject\AmpWP\Tests\Helpers\StubSanitizer; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Test AMP_Base_Sanitizer_Test * * @covers AMP_Base_Sanitizer */ -class AMP_Base_Sanitizer_Test extends WP_UnitTestCase { +class AMP_Base_Sanitizer_Test extends TestCase { /** * Set up. diff --git a/tests/php/test-class-amp-block-sanitizer.php b/tests/php/test-class-amp-block-sanitizer.php index 5c4fae99f06..a897d8519d7 100644 --- a/tests/php/test-class-amp-block-sanitizer.php +++ b/tests/php/test-class-amp-block-sanitizer.php @@ -5,10 +5,12 @@ * @package AMP */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Class AMP_Block_Sanitizer_Test */ -class AMP_Block_Sanitizer_Test extends WP_UnitTestCase { +class AMP_Block_Sanitizer_Test extends TestCase { /** * Get data. diff --git a/tests/php/test-class-amp-cli-validation-command.php b/tests/php/test-class-amp-cli-validation-command.php index 2404ca1c753..3674ef1320a 100644 --- a/tests/php/test-class-amp-cli-validation-command.php +++ b/tests/php/test-class-amp-cli-validation-command.php @@ -9,15 +9,16 @@ use AmpProject\AmpWP\Option; use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; use AmpProject\AmpWP\Tests\Helpers\ValidationRequestMocking; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for Test_AMP_CLI_Validation_Command class. * * @since 1.0 * - * @coversDefaultClass ValidationCommand + * @coversDefaultClass \AmpProject\AmpWP\Cli\ValidationCommand */ -class Test_AMP_CLI_Validation_Command extends WP_UnitTestCase { +class Test_AMP_CLI_Validation_Command extends TestCase { use PrivateAccess, ValidationRequestMocking; @@ -78,6 +79,6 @@ public function test_validate_urls() { // All of the terms created above should be present in $validated_urls. $this->assertEmpty( array_diff( $expected_validated_urls, $actual_validated_urls ) ); - $this->assertContains( home_url( '/' ), $this->get_validated_urls() ); + $this->assertStringContainsString( home_url( '/' ), $this->get_validated_urls() ); } } diff --git a/tests/php/test-class-amp-comments-sanitizer.php b/tests/php/test-class-amp-comments-sanitizer.php index e8e5304f329..396328e0155 100644 --- a/tests/php/test-class-amp-comments-sanitizer.php +++ b/tests/php/test-class-amp-comments-sanitizer.php @@ -5,18 +5,17 @@ * @package AMP */ -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; use AmpProject\Dom\Document; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for AMP_Comments_Sanitizer class. * * @since 0.7 */ -class Test_AMP_Comments_Sanitizer extends WP_UnitTestCase { +class Test_AMP_Comments_Sanitizer extends TestCase { - use AssertContainsCompatibility; use PrivateAccess; /** @@ -48,10 +47,10 @@ public function test_sanitize_incorrect_action() { $form = $this->create_form( 'incorrect-action.php' ); $instance->sanitize(); $on = $form->getAttribute( 'on' ); - $this->assertStringNotContains( 'submit:AMP.setState(', $on ); - $this->assertStringNotContains( 'submit-error:AMP.setState(', $on ); + $this->assertStringNotContainsString( 'submit:AMP.setState(', $on ); + $this->assertStringNotContainsString( 'submit-error:AMP.setState(', $on ); foreach ( $this->get_form_element_names() as $name ) { - $this->assertStringNotContains( $name, $on ); + $this->assertStringNotContainsString( $name, $on ); } } @@ -70,10 +69,10 @@ public function test_sanitize_allowed_action_xhr() { $comments_sanitizer->sanitize(); $on = $form->getAttribute( 'on' ); - $this->assertStringContains( 'submit:AMP.setState(', $on ); - $this->assertStringContains( 'submit-error:AMP.setState(', $on ); + $this->assertStringContainsString( 'submit:AMP.setState(', $on ); + $this->assertStringContainsString( 'submit-error:AMP.setState(', $on ); foreach ( $this->get_form_element_names() as $name ) { - $this->assertStringContains( $name, $on ); + $this->assertStringContainsString( $name, $on ); } } @@ -105,15 +104,15 @@ public function test_process_comment_form() { $on = $form->getAttribute( 'on' ); $amp_state = $this->dom->getElementsByTagName( 'amp-state' )->item( 0 ); - $this->assertStringContains( 'submit:AMP.setState(', $on ); - $this->assertStringContains( 'submit-error:AMP.setState(', $on ); - $this->assertStringContains( 'submit-success:AMP.setState(', $on ); - $this->assertStringContains( strval( $GLOBALS['post']->ID ), $on ); + $this->assertStringContainsString( 'submit:AMP.setState(', $on ); + $this->assertStringContainsString( 'submit-error:AMP.setState(', $on ); + $this->assertStringContainsString( 'submit-success:AMP.setState(', $on ); + $this->assertStringContainsString( strval( $GLOBALS['post']->ID ), $on ); $this->assertEquals( 'script', $amp_state->firstChild->nodeName ); foreach ( $this->get_form_element_names() as $name ) { - $this->assertStringContains( $name, $on ); - $this->assertStringContains( $name, $amp_state->nodeValue ); + $this->assertStringContainsString( $name, $on ); + $this->assertStringContainsString( $name, $amp_state->nodeValue ); } foreach ( $form->getElementsByTagName( 'input' ) as $input ) { /** @@ -122,8 +121,8 @@ public function test_process_comment_form() { * @var DOMElement $input */ $on = $input->getAttribute( 'on' ); - $this->assertStringContains( 'change:AMP.setState(', $on ); - $this->assertStringContains( strval( $GLOBALS['post']->ID ), $on ); + $this->assertStringContainsString( 'change:AMP.setState(', $on ); + $this->assertStringContainsString( strval( $GLOBALS['post']->ID ), $on ); } } diff --git a/tests/php/test-class-amp-content-sanitizer.php b/tests/php/test-class-amp-content-sanitizer.php index c76b0ea3750..e2c46934d40 100644 --- a/tests/php/test-class-amp-content-sanitizer.php +++ b/tests/php/test-class-amp-content-sanitizer.php @@ -1,6 +1,7 @@ assertEmpty( $sanitize_results['styles'] ); - $this->assertInternalType( 'array', $sanitize_results['sanitizers'] ); + $this->assertIsArray( $sanitize_results['sanitizers'] ); $this->assertEqualSets( array_keys( $sanitizers ), array_keys( $sanitize_results['sanitizers'] ) ); $this->assertEquals( 1, $document->getElementsByTagName( 'amp-video' )->length ); foreach ( array_keys( $sanitizers ) as $sanitizer_class ) { diff --git a/tests/php/test-class-amp-core-block-handler.php b/tests/php/test-class-amp-core-block-handler.php index 7442e4e7584..1fdbf473f63 100644 --- a/tests/php/test-class-amp-core-block-handler.php +++ b/tests/php/test-class-amp-core-block-handler.php @@ -6,9 +6,9 @@ * @since 1.0 */ -use AmpProject\AmpWP\Tests\Helpers\AssertContainsCompatibility; use AmpProject\AmpWP\Tests\Helpers\WithoutBlockPreRendering; use AmpProject\AmpWP\Tests\Helpers\MarkupComparison; +use Yoast\WPTestUtils\WPIntegration\TestCase; /** * Tests for AMP_Core_Block_Handler. @@ -16,10 +16,9 @@ * @package AMP * @coversDefaultClass AMP_Core_Block_Handler */ -class Test_AMP_Core_Block_Handler extends WP_UnitTestCase { +class Test_AMP_Core_Block_Handler extends TestCase { use MarkupComparison; - use AssertContainsCompatibility; use WithoutBlockPreRendering { setUp as public prevent_block_pre_render; } @@ -84,26 +83,26 @@ public function test_register_and_unregister_embed() { $handler->register_embed(); $rendered = do_blocks( $categories_block ); - $this->assertStringContains( 'assertStringNotContains( 'onchange', $rendered ); - $this->assertStringContains( 'on="change', $rendered ); + $this->assertStringContainsString( 'assertStringNotContainsString( 'onchange', $rendered ); + $this->assertStringContainsString( 'on="change', $rendered ); if ( WP_Block_Type_Registry::get_instance()->is_registered( 'core/archives' ) ) { $rendered = do_blocks( $archives_block ); - $this->assertStringContains( 'assertStringNotContains( 'onchange', $rendered ); - $this->assertStringContains( 'on="change', $rendered ); + $this->assertStringContainsString( 'assertStringNotContainsString( 'onchange', $rendered ); + $this->assertStringContainsString( 'on="change', $rendered ); } $handler->unregister_embed(); $rendered = do_blocks( $categories_block ); - $this->assertStringContains( 'assertStringContains( 'onchange', $rendered ); - $this->assertStringNotContains( 'on="change', $rendered ); + $this->assertStringContainsString( 'assertStringContainsString( 'onchange', $rendered ); + $this->assertStringNotContainsString( 'on="change', $rendered ); if ( WP_Block_Type_Registry::get_instance()->is_registered( 'core/archives' ) ) { $rendered = do_blocks( $archives_block ); - $this->assertStringContains( 'assertStringContains( 'onchange', $rendered ); - $this->assertStringNotContains( 'on="change', $rendered ); + $this->assertStringContainsString( 'assertStringContainsString( 'onchange', $rendered ); + $this->assertStringNotContainsString( 'on="change', $rendered ); } } @@ -153,7 +152,7 @@ public function test_ampify_video_block() { $content = apply_filters( 'the_content', get_post( $post_id )->post_content ); - $this->assertStringContains( '