id summary reporter owner description type status priority milestone component version severity resolution keywords cc focuses 53844 Fix four warnings in the test suite jrf hellofromTonya "Follow up after the projected changes for ticket #46149, which are expected to be committed soon. When the WP Core tests are run on PHPUnit 8.x and 9.x, four - non-blocking - warnings will be displayed: {{{ There were 4 warnings: 1) Tests_REST_Request::test_route_level_validate_callback createPartialMock called with method(s) __invoke that do not exist in stdClass. This will not be allowed in future versions of PHPUnit. 2) Tests_REST_Request::test_route_level_validate_callback_no_parameter_callbacks createPartialMock called with method(s) __invoke that do not exist in stdClass. This will not be allowed in future versions of PHPUnit. 3) Tests_REST_Request::test_route_level_validate_callback_is_not_executed_if_parameter_validation_fails createPartialMock called with method(s) __invoke that do not exist in stdClass. This will not be allowed in future versions of PHPUnit. 4) Tests_REST_Server::test_callbacks_are_not_executed_if_request_validation_fails createPartialMock called with method(s) __invoke that do not exist in stdClass. This will not be allowed in future versions of PHPUnit. }}} These warnings relate to the following code pattern which is used in all four of the referenced tests: {{{#!php createPartialMock( 'stdClass', array( '__invoke' ) ); }}} The PHP native `stdClass` class does not have the `__invoke()` method declared. As these warnings are currently non-blocking, they will not be addressed in ticket #46149. However, they should be addressed in the foreseeable future to prevent this becoming a blocker once PHPUnit 10 will be released. Typically, this could be solved by declaring a dummy anonymous class with an `__invoke()` method, used only in the test suite, but anonymous classes is a PHP 7.0+ feature and can therefore not be used. I suspect the best way to solve these warnings in a PHP cross-version compatible manner, will be to create a dummy class with an `__invoke()` method, as a test fixture and switching out the use of `stdClass` in these test methods in favour of using the dummy class." defect (bug) closed normal 5.9 Build/Test Tools normal fixed has-patch commit has-unit-tests rest-api