From 5fe6f930bd7ac82f8de3d27e07434d0f47bfc8f3 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Fri, 18 Nov 2022 18:20:09 +0000 Subject: [PATCH] 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 * https://github.com/sebastianbergmann/phpunit/issues/3511 * https://github.com/sebastianbergmann/phpunit/commit/6205f335954d00fa01992fe324a7eefbc954449e 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 --- composer.json | 5 +- tests/phpunit/includes/phpunit6/compat.php | 4 +- .../MockObject/Builder/NamespaceMatch.php | 43 --- .../MockObject/Builder/ParametersMatch.php | 66 ---- .../MockObject/Generator/deprecation.tpl.dist | 2 - .../Generator/mocked_class.tpl.dist | 46 --- .../Generator/mocked_class_method.tpl.dist | 8 - .../Generator/mocked_clone.tpl.dist | 4 - .../Generator/mocked_method.tpl.dist | 22 -- .../Generator/mocked_method_void.tpl.dist | 20 - .../Generator/mocked_static_method.tpl.dist | 5 - .../Generator/proxied_method.tpl.dist | 26 -- .../Generator/proxied_method_void.tpl.dist | 26 -- .../MockObject/Generator/trait_class.tpl.dist | 4 - .../Generator/unmocked_clone.tpl.dist | 5 - .../MockObject/Generator/wsdl_class.tpl.dist | 7 - .../MockObject/Generator/wsdl_method.tpl.dist | 4 - .../phpunit7/MockObject/InvocationMocker.php | 192 --------- .../includes/phpunit7/MockObject/LICENSE | 33 -- .../phpunit7/MockObject/MockMethod.php | 363 ------------------ tests/phpunit/includes/phpunit7/testcase.php | 40 -- .../tests/category/wpListCategories.php | 16 +- .../tests/comment/getPageOfComment.php | 4 +- tests/phpunit/tests/comment/query.php | 5 - tests/phpunit/tests/compat.php | 2 +- tests/phpunit/tests/http/http.php | 2 +- tests/phpunit/tests/media.php | 26 +- tests/phpunit/tests/post/getTheContent.php | 4 +- 28 files changed, 34 insertions(+), 950 deletions(-) delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Builder/NamespaceMatch.php delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Builder/ParametersMatch.php delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/deprecation.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class_method.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_clone.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method_void.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_static_method.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method_void.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/trait_class.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/unmocked_clone.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_class.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_method.tpl.dist delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/InvocationMocker.php delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/LICENSE delete mode 100644 tests/phpunit/includes/phpunit7/MockObject/MockMethod.php delete mode 100644 tests/phpunit/includes/phpunit7/testcase.php diff --git a/composer.json b/composer.json index 0411e248f99..c83330fbc1c 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,9 @@ } }, "scripts": { - "backport": "bin/backport-wp-commit.sh" + "backport": "bin/backport-wp-commit.sh", + "phpcs": "vendor/bin/phpcs -n", + "phpcs-tests": "vendor/bin/phpcs -n tests", + "phpunit": "vendor/bin/phpunit" } } diff --git a/tests/phpunit/includes/phpunit6/compat.php b/tests/phpunit/includes/phpunit6/compat.php index e6eea5e7403..77099ef1530 100644 --- a/tests/phpunit/includes/phpunit6/compat.php +++ b/tests/phpunit/includes/phpunit6/compat.php @@ -14,6 +14,8 @@ class_alias( 'PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_Assert class_alias( 'PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite' ); class_alias( 'PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener' ); class_alias( 'PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState' ); - class_alias( 'PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt' ); class_alias( 'PHPUnit\Util\Test', 'PHPUnit_Util_Test' ); + if ( class_exists( 'PHPUnit\Util\Getopt' ) ) { + class_alias( 'PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt' ); + } } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Builder/NamespaceMatch.php b/tests/phpunit/includes/phpunit7/MockObject/Builder/NamespaceMatch.php deleted file mode 100644 index 99f21e745ac..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Builder/NamespaceMatch.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace PHPUnit\Framework\MockObject\Builder; - -/** - * Interface for builders which can register builders with a given identification. - * - * This interface relates to Identity. - */ -interface NamespaceMatch -{ - /** - * Looks up the match builder with identification $id and returns it. - * - * @param string $id The identification of the match builder - * - * @return Match - */ - public function lookupId($id); - - /** - * Registers the match builder $builder with the identification $id. The - * builder can later be looked up using lookupId() to figure out if it - * has been invoked. - * - * @param string $id The identification of the match builder - * @param Match $builder The builder which is being registered - */ - public function registerId($id, ParametersMatch $builder); -} diff --git a/tests/phpunit/includes/phpunit7/MockObject/Builder/ParametersMatch.php b/tests/phpunit/includes/phpunit7/MockObject/Builder/ParametersMatch.php deleted file mode 100644 index 327557541b6..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Builder/ParametersMatch.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace PHPUnit\Framework\MockObject\Builder; - -use PHPUnit\Framework\MockObject\Matcher\AnyParameters; - -/** - * Builder interface for parameter matchers. - */ -interface ParametersMatch extends Stub -{ - /** - * Defines the expectation which must occur before the current is valid. - * - * @param string $id the identification of the expectation that should - * occur before this one - * - * @return Stub - */ - public function after($id); - - /** - * Sets the parameters to match for, each parameter to this function will - * be part of match. To perform specific matches or constraints create a - * new PHPUnit\Framework\Constraint\Constraint and use it for the parameter. - * If the parameter value is not a constraint it will use the - * PHPUnit\Framework\Constraint\IsEqual for the value. - * - * Some examples: - * - * // match first parameter with value 2 - * $b->with(2); - * // match first parameter with value 'smock' and second identical to 42 - * $b->with('smock', new PHPUnit\Framework\Constraint\IsEqual(42)); - * - * - * @return ParametersMatch - */ - public function with(...$arguments); - - /** - * Sets a matcher which allows any kind of parameters. - * - * Some examples: - * - * // match any number of parameters - * $b->withAnyParameters(); - * - * - * @return AnyParameters - */ - public function withAnyParameters(); -} diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/deprecation.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/deprecation.tpl.dist deleted file mode 100644 index 5bf06f52de1..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/deprecation.tpl.dist +++ /dev/null @@ -1,2 +0,0 @@ - - @trigger_error({deprecation}, E_USER_DEPRECATED); diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class.tpl.dist deleted file mode 100644 index 4b68a2b2b68..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class.tpl.dist +++ /dev/null @@ -1,46 +0,0 @@ -{prologue}{class_declaration} -{ - private $__phpunit_invocationMocker; - private $__phpunit_originalObject; - private $__phpunit_configurable = {configurable}; - private $__phpunit_returnValueGeneration = true; - -{clone}{mocked_methods} - public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher) - { - return $this->__phpunit_getInvocationMocker()->expects($matcher); - } -{method} - public function __phpunit_setOriginalObject($originalObject) - { - $this->__phpunit_originalObject = $originalObject; - } - - public function __phpunit_setReturnValueGeneration(bool $returnValueGeneration) - { - $this->__phpunit_returnValueGeneration = $returnValueGeneration; - } - - public function __phpunit_getInvocationMocker() - { - if ($this->__phpunit_invocationMocker === null) { - $this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable, $this->__phpunit_returnValueGeneration); - } - - return $this->__phpunit_invocationMocker; - } - - public function __phpunit_hasMatchers() - { - return $this->__phpunit_getInvocationMocker()->hasMatchers(); - } - - public function __phpunit_verify(bool $unsetInvocationMocker = true) - { - $this->__phpunit_getInvocationMocker()->verify(); - - if ($unsetInvocationMocker) { - $this->__phpunit_invocationMocker = null; - } - } -}{epilogue} diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class_method.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class_method.tpl.dist deleted file mode 100644 index d6a036f4ce0..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_class_method.tpl.dist +++ /dev/null @@ -1,8 +0,0 @@ - - public function method() - { - $any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount; - $expects = $this->expects($any); - - return call_user_func_array([$expects, 'method'], func_get_args()); - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_clone.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_clone.tpl.dist deleted file mode 100644 index bd846dee76e..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_clone.tpl.dist +++ /dev/null @@ -1,4 +0,0 @@ - public function __clone() - { - $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method.tpl.dist deleted file mode 100644 index 3adf2f0269c..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method.tpl.dist +++ /dev/null @@ -1,22 +0,0 @@ - - {modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type} - {{deprecation} - $__phpunit_arguments = [{arguments_call}]; - $__phpunit_count = func_num_args(); - - if ($__phpunit_count > {arguments_count}) { - $__phpunit_arguments_tmp = func_get_args(); - - for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { - $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; - } - } - - $__phpunit_result = $this->__phpunit_getInvocationMocker()->invoke( - new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation( - '{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments} - ) - ); - - return $__phpunit_result; - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method_void.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method_void.tpl.dist deleted file mode 100644 index 3813fe4b9d9..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_method_void.tpl.dist +++ /dev/null @@ -1,20 +0,0 @@ - - {modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type} - {{deprecation} - $__phpunit_arguments = [{arguments_call}]; - $__phpunit_count = func_num_args(); - - if ($__phpunit_count > {arguments_count}) { - $__phpunit_arguments_tmp = func_get_args(); - - for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { - $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; - } - } - - $this->__phpunit_getInvocationMocker()->invoke( - new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation( - '{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments} - ) - ); - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_static_method.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_static_method.tpl.dist deleted file mode 100644 index 56b561b65f2..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/mocked_static_method.tpl.dist +++ /dev/null @@ -1,5 +0,0 @@ - - {modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type} - { - throw new \PHPUnit\Framework\MockObject\BadMethodCallException('Static method "{method_name}" cannot be invoked on mock object'); - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method.tpl.dist deleted file mode 100644 index 4dd87cd725d..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method.tpl.dist +++ /dev/null @@ -1,26 +0,0 @@ - - {modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type} - { - $__phpunit_arguments = [{arguments_call}]; - $__phpunit_count = func_num_args(); - - if ($__phpunit_count > {arguments_count}) { - $__phpunit_arguments_tmp = func_get_args(); - - for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { - $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; - } - } - - $__phpunit_invocation = new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation( - '{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments} - ); - - $__phpunit_invocation->setProxiedCall(); - - $this->__phpunit_getInvocationMocker()->invoke($__phpunit_invocation); - - unset($__phpunit_invocation); - - return call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $__phpunit_arguments); - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method_void.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method_void.tpl.dist deleted file mode 100644 index 0d868f25273..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/proxied_method_void.tpl.dist +++ /dev/null @@ -1,26 +0,0 @@ - - {modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type} - { - $__phpunit_arguments = [{arguments_call}]; - $__phpunit_count = func_num_args(); - - if ($__phpunit_count > {arguments_count}) { - $__phpunit_arguments_tmp = func_get_args(); - - for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) { - $__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i]; - } - } - - $__phpunit_invocation = new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation( - '{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments} - ); - - $__phpunit_invocation->setProxiedCall(); - - $this->__phpunit_getInvocationMocker()->invoke($__phpunit_invocation); - - unset($__phpunit_invocation); - - call_user_func_array(array($this->__phpunit_originalObject, "{method_name}"), $__phpunit_arguments); - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/trait_class.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/trait_class.tpl.dist deleted file mode 100644 index 4143b0f66af..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/trait_class.tpl.dist +++ /dev/null @@ -1,4 +0,0 @@ -{prologue}class {class_name} -{ - use {trait_name}; -} diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/unmocked_clone.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/unmocked_clone.tpl.dist deleted file mode 100644 index fa0e70abc2f..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/unmocked_clone.tpl.dist +++ /dev/null @@ -1,5 +0,0 @@ - public function __clone() - { - $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); - parent::__clone(); - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_class.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_class.tpl.dist deleted file mode 100644 index cc69fd341cc..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_class.tpl.dist +++ /dev/null @@ -1,7 +0,0 @@ -{namespace}class {class_name} extends \SoapClient -{ - public function __construct($wsdl, array $options) - { - parent::__construct('{wsdl}', $options); - } -{methods}} diff --git a/tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_method.tpl.dist b/tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_method.tpl.dist deleted file mode 100644 index bb16e763eba..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/Generator/wsdl_method.tpl.dist +++ /dev/null @@ -1,4 +0,0 @@ - - public function {method_name}({arguments}) - { - } diff --git a/tests/phpunit/includes/phpunit7/MockObject/InvocationMocker.php b/tests/phpunit/includes/phpunit7/MockObject/InvocationMocker.php deleted file mode 100644 index 3a3881e976b..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/InvocationMocker.php +++ /dev/null @@ -1,192 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace PHPUnit\Framework\MockObject; - -use Exception; -use PHPUnit\Framework\ExpectationFailedException; -use PHPUnit\Framework\MockObject\Builder\InvocationMocker as BuilderInvocationMocker; -use PHPUnit\Framework\MockObject\Builder\ParametersMatch; -use PHPUnit\Framework\MockObject\Builder\NamespaceMatch; -use PHPUnit\Framework\MockObject\Matcher\DeferredError; -use PHPUnit\Framework\MockObject\Matcher\Invocation as MatcherInvocation; -use PHPUnit\Framework\MockObject\Stub\MatcherCollection; - -/** - * Mocker for invocations which are sent from - * MockObject objects. - * - * Keeps track of all expectations and stubs as well as registering - * identifications for builders. - */ -class InvocationMocker implements Invokable, MatcherCollection, NamespaceMatch -{ - /** - * @var MatcherInvocation[] - */ - private $matchers = []; - - /** - * @var Match[] - */ - private $builderMap = []; - - /** - * @var string[] - */ - private $configurableMethods; - - /** - * @var bool - */ - private $returnValueGeneration; - - public function __construct(array $configurableMethods, bool $returnValueGeneration) - { - $this->configurableMethods = $configurableMethods; - $this->returnValueGeneration = $returnValueGeneration; - } - - public function addMatcher(MatcherInvocation $matcher): void - { - $this->matchers[] = $matcher; - } - - public function hasMatchers() - { - foreach ($this->matchers as $matcher) { - if ($matcher->hasMatchers()) { - return true; - } - } - - return false; - } - - /** - * @return null|bool - */ - public function lookupId($id) - { - if (isset($this->builderMap[$id])) { - return $this->builderMap[$id]; - } - } - - /** - * @throws RuntimeException - */ - public function registerId($id, ParametersMatch $builder): void - { - if (isset($this->builderMap[$id])) { - throw new RuntimeException( - 'Match builder with id <' . $id . '> is already registered.' - ); - } - - $this->builderMap[$id] = $builder; - } - - /** - * @return BuilderInvocationMocker - */ - public function expects(MatcherInvocation $matcher) - { - return new BuilderInvocationMocker( - $this, - $matcher, - $this->configurableMethods - ); - } - - /** - * @throws Exception - */ - public function invoke(Invocation $invocation) - { - $exception = null; - $hasReturnValue = false; - $returnValue = null; - - foreach ($this->matchers as $match) { - try { - if ($match->matches($invocation)) { - $value = $match->invoked($invocation); - - if (!$hasReturnValue) { - $returnValue = $value; - $hasReturnValue = true; - } - } - } catch (Exception $e) { - $exception = $e; - } - } - - if ($exception !== null) { - throw $exception; - } - - if ($hasReturnValue) { - return $returnValue; - } - - if ($this->returnValueGeneration === false) { - $exception = new ExpectationFailedException( - \sprintf( - 'Return value inference disabled and no expectation set up for %s::%s()', - $invocation->getClassName(), - $invocation->getMethodName() - ) - ); - - if (\strtolower($invocation->getMethodName()) === '__tostring') { - $this->addMatcher(new DeferredError($exception)); - - return ''; - } - - throw $exception; - } - - return $invocation->generateReturnValue(); - } - - /** - * @return bool - */ - public function matches(Invocation $invocation) - { - foreach ($this->matchers as $matcher) { - if (!$matcher->matches($invocation)) { - return false; - } - } - - return true; - } - - /** - * @throws \PHPUnit\Framework\ExpectationFailedException - * - * @return bool - */ - public function verify() - { - foreach ($this->matchers as $matcher) { - $matcher->verify(); - } - } -} diff --git a/tests/phpunit/includes/phpunit7/MockObject/LICENSE b/tests/phpunit/includes/phpunit7/MockObject/LICENSE deleted file mode 100644 index 46fabcbdf9e..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/LICENSE +++ /dev/null @@ -1,33 +0,0 @@ -PHPUnit - -Copyright (c) 2001-2019, Sebastian Bergmann . -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - * Neither the name of Sebastian Bergmann nor the names of his - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/phpunit/includes/phpunit7/MockObject/MockMethod.php b/tests/phpunit/includes/phpunit7/MockObject/MockMethod.php deleted file mode 100644 index 6e08753f426..00000000000 --- a/tests/phpunit/includes/phpunit7/MockObject/MockMethod.php +++ /dev/null @@ -1,363 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace PHPUnit\Framework\MockObject; - -use ReflectionClass; -use ReflectionException; -use ReflectionMethod; -use Text_Template; - -final class MockMethod -{ - /** - * @var Text_Template[] - */ - private static $templates = []; - - /** - * @var string - */ - private $className; - - /** - * @var string - */ - private $methodName; - - /** - * @var bool - */ - private $cloneArguments; - - /** - * @var string string - */ - private $modifier; - - /** - * @var string - */ - private $argumentsForDeclaration; - - /** - * @var string - */ - private $argumentsForCall; - - /** - * @var string - */ - private $returnType; - - /** - * @var string - */ - private $reference; - - /** - * @var bool - */ - private $callOriginalMethod; - - /** - * @var bool - */ - private $static; - - /** - * @var ?string - */ - private $deprecation; - - /** - * @var bool - */ - private $allowsReturnNull; - - public static function fromReflection(ReflectionMethod $method, bool $callOriginalMethod, bool $cloneArguments): self - { - if ($method->isPrivate()) { - $modifier = 'private'; - } elseif ($method->isProtected()) { - $modifier = 'protected'; - } else { - $modifier = 'public'; - } - - if ($method->isStatic()) { - $modifier .= ' static'; - } - - if ($method->returnsReference()) { - $reference = '&'; - } else { - $reference = ''; - } - - if ($method->hasReturnType()) { - $returnType = $method->getReturnType()->getName(); - } else { - $returnType = ''; - } - - $docComment = $method->getDocComment(); - - if (\is_string($docComment) - && \preg_match('#\*[ \t]*+@deprecated[ \t]*+(.*?)\r?+\n[ \t]*+\*(?:[ \t]*+@|/$)#s', $docComment, $deprecation) - ) { - $deprecation = \trim(\preg_replace('#[ \t]*\r?\n[ \t]*+\*[ \t]*+#', ' ', $deprecation[1])); - } else { - $deprecation = null; - } - - return new self( - $method->getDeclaringClass()->getName(), - $method->getName(), - $cloneArguments, - $modifier, - self::getMethodParameters($method), - self::getMethodParameters($method, true), - $returnType, - $reference, - $callOriginalMethod, - $method->isStatic(), - $deprecation, - $method->hasReturnType() && $method->getReturnType()->allowsNull() - ); - } - - public static function fromName(string $fullClassName, string $methodName, bool $cloneArguments): self - { - return new self( - $fullClassName, - $methodName, - $cloneArguments, - 'public', - '', - '', - '', - '', - false, - false, - null, - false - ); - } - - public function __construct(string $className, string $methodName, bool $cloneArguments, string $modifier, string $argumentsForDeclaration, string $argumentsForCall, string $returnType, string $reference, bool $callOriginalMethod, bool $static, ?string $deprecation, bool $allowsReturnNull) - { - $this->className = $className; - $this->methodName = $methodName; - $this->cloneArguments = $cloneArguments; - $this->modifier = $modifier; - $this->argumentsForDeclaration = $argumentsForDeclaration; - $this->argumentsForCall = $argumentsForCall; - $this->returnType = $returnType; - $this->reference = $reference; - $this->callOriginalMethod = $callOriginalMethod; - $this->static = $static; - $this->deprecation = $deprecation; - $this->allowsReturnNull = $allowsReturnNull; - } - - public function getName(): string - { - return $this->methodName; - } - - /** - * @throws \ReflectionException - * @throws \PHPUnit\Framework\MockObject\RuntimeException - * @throws \InvalidArgumentException - */ - public function generateCode(): string - { - if ($this->static) { - $templateFile = 'mocked_static_method.tpl'; - } elseif ($this->returnType === 'void') { - $templateFile = \sprintf( - '%s_method_void.tpl', - $this->callOriginalMethod ? 'proxied' : 'mocked' - ); - } else { - $templateFile = \sprintf( - '%s_method.tpl', - $this->callOriginalMethod ? 'proxied' : 'mocked' - ); - } - - $returnType = $this->returnType; - // @see https://bugs.php.net/bug.php?id=70722 - if ($returnType === 'self') { - $returnType = $this->className; - } - - // @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/406 - if ($returnType === 'parent') { - $reflector = new ReflectionClass($this->className); - - $parentClass = $reflector->getParentClass(); - - if ($parentClass === false) { - throw new RuntimeException( - \sprintf( - 'Cannot mock %s::%s because "parent" return type declaration is used but %s does not have a parent class', - $this->className, - $this->methodName, - $this->className - ) - ); - } - - $returnType = $parentClass->getName(); - } - - $deprecation = $this->deprecation; - - if (null !== $this->deprecation) { - $deprecation = "The $this->className::$this->methodName method is deprecated ($this->deprecation)."; - $deprecationTemplate = $this->getTemplate('deprecation.tpl'); - - $deprecationTemplate->setVar([ - 'deprecation' => \var_export($deprecation, true), - ]); - - $deprecation = $deprecationTemplate->render(); - } - - $template = $this->getTemplate($templateFile); - - $template->setVar( - [ - 'arguments_decl' => $this->argumentsForDeclaration, - 'arguments_call' => $this->argumentsForCall, - 'return_delim' => $returnType ? ': ' : '', - 'return_type' => $this->allowsReturnNull ? '?' . $returnType : $returnType, - 'arguments_count' => !empty($this->argumentsForCall) ? \substr_count($this->argumentsForCall, ',') + 1 : 0, - 'class_name' => $this->className, - 'method_name' => $this->methodName, - 'modifier' => $this->modifier, - 'reference' => $this->reference, - 'clone_arguments' => $this->cloneArguments ? 'true' : 'false', - 'deprecation' => $deprecation, - ] - ); - - return $template->render(); - } - - private function getTemplate(string $template): Text_Template - { - $filename = __DIR__ . \DIRECTORY_SEPARATOR . 'Generator' . \DIRECTORY_SEPARATOR . $template; - - if (!isset(self::$templates[$filename])) { - self::$templates[$filename] = new Text_Template($filename); - } - - return self::$templates[$filename]; - } - - /** - * Returns the parameters of a function or method. - * - * @throws RuntimeException - */ - private static function getMethodParameters(ReflectionMethod $method, bool $forCall = false): string - { - $parameters = []; - - foreach ($method->getParameters() as $i => $parameter) { - $name = '$' . $parameter->getName(); - - /* Note: PHP extensions may use empty names for reference arguments - * or "..." for methods taking a variable number of arguments. - */ - if ($name === '$' || $name === '$...') { - $name = '$arg' . $i; - } - - if ($parameter->isVariadic()) { - if ($forCall) { - continue; - } - - $name = '...' . $name; - } - - $nullable = ''; - $default = ''; - $reference = ''; - $typeDeclaration = ''; - - if (!$forCall) { - if ($parameter->hasType() && $parameter->allowsNull()) { - $nullable = '?'; - } - - if ($parameter->hasType() && $parameter->getType()->getName() !== 'self') { - $typeDeclaration = $parameter->getType()->getName() . ' '; - } else { - try { - $class = $parameter->getType() && !$parameter->getType()->isBuiltin() - ? new ReflectionClass($parameter->getType()->getName()) - : null; - } catch (ReflectionException $e) { - throw new RuntimeException( - \sprintf( - 'Cannot mock %s::%s() because a class or ' . - 'interface used in the signature is not loaded', - $method->getDeclaringClass()->getName(), - $method->getName() - ), - 0, - $e - ); - } - - if ($class !== null) { - $typeDeclaration = $class->getName() . ' '; - } - } - - if (!$parameter->isVariadic()) { - if ($parameter->isDefaultValueAvailable()) { - try { - $value = \var_export($parameter->getDefaultValue(), true); - } catch (\ReflectionException $e) { - throw new RuntimeException( - $e->getMessage(), - (int) $e->getCode(), - $e - ); - } - - $default = ' = ' . $value; - } elseif ($parameter->isOptional()) { - $default = ' = null'; - } - } - } - - if ($parameter->isPassedByReference()) { - $reference = '&'; - } - - $parameters[] = $nullable . $typeDeclaration . $reference . $name . $default; - } - - return \implode(', ', $parameters); - } -} diff --git a/tests/phpunit/includes/phpunit7/testcase.php b/tests/phpunit/includes/phpunit7/testcase.php deleted file mode 100644 index da4a348c877..00000000000 --- a/tests/phpunit/includes/phpunit7/testcase.php +++ /dev/null @@ -1,40 +0,0 @@ -assertStringNotContainsString( 'Test Cat 1', $found ); } + public function list_cats_callback( $cat ) { + if ( 'Test Cat 1' === $cat ) { + return ''; + } + + return $cat; + } + public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() { $cats = self::factory()->category->create_many( 2 ); @@ -247,14 +255,6 @@ public function test_show_option_all_link_should_link_to_post_archive_if_no_asso $this->assertStringContainsString( "
  • All
  • ", $found ); } - public function list_cats_callback( $cat ) { - if ( 'Test Cat 1' === $cat ) { - return ''; - } - - return $cat; - } - /** * @see https://core.trac.wordpress.org/ticket/33460 */ diff --git a/tests/phpunit/tests/comment/getPageOfComment.php b/tests/phpunit/tests/comment/getPageOfComment.php index a0699b7557a..2f31e95c360 100644 --- a/tests/phpunit/tests/comment/getPageOfComment.php +++ b/tests/phpunit/tests/comment/getPageOfComment.php @@ -545,7 +545,7 @@ public function test_page_number_when_unapproved_comments_are_included_for_curre remove_filter( 'wp_get_current_commenter', array( $this, 'get_current_commenter' ) ); - $this->assertContains( $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); + $this->assertContains( (string) $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); } /** @@ -594,7 +594,7 @@ public function test_page_number_when_unapproved_comments_are_included_for_curre ) ); - $this->assertContains( $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); + $this->assertContains( (string) $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); wp_set_current_user( $current_user ); } diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index f3377ce6be6..9d613b06d81 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -2496,7 +2496,6 @@ public function test_search_false_should_be_ignored() { 'search' => false, ) ); - $this->assertStringNotContainsString( 'comment_author LIKE', $q->request ); } @@ -2510,7 +2509,6 @@ public function test_search_null_should_be_ignored() { 'search' => null, ) ); - $this->assertStringNotContainsString( 'comment_author LIKE', $q->request ); } @@ -2524,7 +2522,6 @@ public function test_search_empty_string_should_be_ignored() { 'search' => false, ) ); - $this->assertStringNotContainsString( 'comment_author LIKE', $q->request ); } @@ -2539,7 +2536,6 @@ public function test_search_int_0_should_not_be_ignored() { 'search' => 0, ) ); - $this->assertStringContainsString( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) ); } @@ -2554,7 +2550,6 @@ public function test_search_string_0_should_not_be_ignored() { 'search' => '0', ) ); - $this->assertStringContainsString( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) ); } diff --git a/tests/phpunit/tests/compat.php b/tests/phpunit/tests/compat.php index 3c6e581953e..32ed1d49aca 100644 --- a/tests/phpunit/tests/compat.php +++ b/tests/phpunit/tests/compat.php @@ -181,7 +181,7 @@ function test_hash_hmac_output() { } function test_json_encode_decode() { - $this->expectException( 'PHPUnit\Framework\Error\Notice' ); + $this->expectNotice( 'PHPUnit\Framework\Error\Notice' ); require_once ABSPATH . WPINC . '/class-json.php'; $json = new Services_JSON(); diff --git a/tests/phpunit/tests/http/http.php b/tests/phpunit/tests/http/http.php index d2670e45c5b..45b5dbe8f29 100644 --- a/tests/phpunit/tests/http/http.php +++ b/tests/phpunit/tests/http/http.php @@ -403,7 +403,7 @@ function test_classicpress_user_agent_full() { $ua_full ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#&site=[0-9a-f]{40}$#', $ua_full ); diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 14a5aebb3e6..11b419d66c1 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -2687,7 +2687,7 @@ function test_wp_img_tag_add_loading_attr() { $img = ' width='; $img = wp_img_tag_add_loading_attr( $img, 'test' ); - $this->assertContains( ' loading="lazy"', $img ); + $this->assertStringContainsString( ' loading="lazy"', $img ); } /** @@ -2698,7 +2698,7 @@ function test_wp_img_tag_add_loading_attr_without_src() { $img = ' width='; $img = wp_img_tag_add_loading_attr( $img, 'test' ); - $this->assertNotContains( ' loading=', $img ); + $this->assertStringNotContainsString( ' loading=', $img ); } /** @@ -2709,11 +2709,11 @@ function test_wp_img_tag_add_loading_attr_with_single_quotes() { $img = " width="; $img = wp_img_tag_add_loading_attr( $img, 'test' ); - $this->assertNotContains( ' loading=', $img ); + $this->assertStringNotContainsString( ' loading=', $img ); // Test specifically that the attribute is not there with double-quotes, // to avoid regressions. - $this->assertNotContains( ' loading="lazy"', $img ); + $this->assertStringNotContainsString( ' loading="lazy"', $img ); } /** @@ -2724,7 +2724,7 @@ function test_wp_img_tag_add_loading_attr_opt_out() { $img = ' width='; add_filter( 'wp_img_tag_add_loading_attr', '__return_false' ); - $this->assertNotContains( ' loading=', $img ); + $this->assertStringNotContainsString( ' loading=', $img ); } /** @@ -2734,7 +2734,7 @@ function test_wp_iframe_tag_add_loading_attr() { $iframe = ''; $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); - $this->assertContains( ' loading="lazy"', $iframe ); + $this->assertStringContainsString( ' loading="lazy"', $iframe ); } /** @@ -2744,7 +2744,7 @@ function test_wp_iframe_tag_add_loading_attr_without_src() { $iframe = ''; $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); - $this->assertNotContains( ' loading=', $iframe ); + $this->assertStringNotContainsString( ' loading=', $iframe ); } /** @@ -2754,11 +2754,11 @@ function test_wp_iframe_tag_add_loading_attr_with_single_quotes() { $iframe = ""; $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); - $this->assertNotContains( ' loading=', $iframe ); + $this->assertStringNotContainsString( ' loading=', $iframe ); // Test specifically that the attribute is not there with double-quotes, // to avoid regressions. - $this->assertNotContains( ' loading="lazy"', $iframe ); + $this->assertStringNotContainsString( ' loading="lazy"', $iframe ); } /** @@ -2768,7 +2768,7 @@ function test_wp_iframe_tag_add_loading_attr_opt_out() { $iframe = ''; add_filter( 'wp_iframe_tag_add_loading_attr', '__return_false' ); - $this->assertNotContains( ' loading=', $iframe ); + $this->assertStringNotContainsString( ' loading=', $iframe ); } /** @@ -2778,7 +2778,7 @@ function test_wp_iframe_tag_add_loading_attr_opt_out() { function test_wp_get_attachment_image_loading() { $img = wp_get_attachment_image( self::$large_id ); - $this->assertContains( ' loading="lazy"', $img ); + $this->assertStringContainsString( ' loading="lazy"', $img ); } /** @@ -2790,7 +2790,7 @@ function test_wp_get_attachment_image_loading_opt_out() { $img = wp_get_attachment_image( self::$large_id ); // There should not be any loading attribute in this case. - $this->assertNotContains( ' loading=', $img ); + $this->assertStringNotContainsString( ' loading=', $img ); } /** @@ -2805,7 +2805,7 @@ function test_wp_get_attachment_image_loading_opt_out_individual() { $img = wp_get_attachment_image( self::$large_id, 'thumbnail', false, array( 'loading' => false ) ); // There should not be any loading attribute in this case. - $this->assertNotContains( ' loading=', $img ); + $this->assertStringNotContainsString( ' loading=', $img ); } /** diff --git a/tests/phpunit/tests/post/getTheContent.php b/tests/phpunit/tests/post/getTheContent.php index 54b8fe318ee..91f0b621f37 100644 --- a/tests/phpunit/tests/post/getTheContent.php +++ b/tests/phpunit/tests/post/getTheContent.php @@ -19,7 +19,7 @@ public function test_argument_back_compat_more_link_text() { $found = get_the_content( 'Ping' ); } - $this->assertContains( '>Ping<', $found ); + $this->assertStringContainsString( '>Ping<', $found ); } /** @@ -38,7 +38,7 @@ public function test_argument_back_compat_strip_teaser() { $found = get_the_content( null, true ); } - $this->assertNotContains( 'Foo', $found ); + $this->assertStringNotContainsString( 'Foo', $found ); } /**