Make WordPress Core


Ignore:
Timestamp:
11/01/2021 10:22:49 PM (3 years ago)
Author:
hellofromTonya
Message:

Build/Test Tools: Ignore "null to nullable" deprecations for select tests.

Adds an expectation for PHP 8.1 "passing null to non-nullable" deprecation notice to select tests where the deprecation is generated by one of the functions in the wp-includes/formatting.php file, either via a filter hook callback or by a direct call.

Instead of haphazardly fixing these issues exposed by the tests, a more structural and all-encompassing solution for input validation should be architected and implemented as otherwise, we'll keep running into similar issues time and again with each new PHP version.

To discourage people from "fixing" these issues now anyway, this commit "hides" nearly all of these issues from the test runs.

Once a more structural solution is designed, these tests and the underlying functions causing the deprecation notices should be revisited and the structural solution put in place.

Includes a few minor other tweaks to select tests:

  • Removing a stray return (twice) from assertion statements.
  • Removing calls to ob_*() functions in favour of letting PHPUnit manage the output catching. This prevents warnings along the lines of Test code or tested code did not (only) close its own output buffers.

Props jrf, hellofromTonya.
See #53635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/mw/editPost.php

    r51587 r51968  
    302302     */
    303303    function test_draft_not_prematurely_published() {
     304        if ( PHP_VERSION_ID >= 80100 ) {
     305            /*
     306             * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
     307             * via hooked in filter functions until a more structural solution to the
     308             * "missing input validation" conundrum has been architected and implemented.
     309             */
     310            $this->expectDeprecation();
     311            $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
     312        }
     313
    304314        $editor_id = $this->make_user_by_role( 'editor' );
    305315
Note: See TracChangeset for help on using the changeset viewer.