Make WordPress Core

Changeset 51572


Ignore:
Timestamp:
08/07/2021 11:00:52 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Build/Test Tools: Handle removal of TestCase::getAnnotations().

The PHPUnit native TestCase::getAnnotations() method is used to check for WP flavored deprecation notices, however, this method was not covered by the backward compatibility promise for PHPUnit (and was annotated as excluded).

The method has been removed as part of an internal refactor in commit sebastianbergmann/phpunit@6858204, which is included in PHPUnit 9.5.0.

For now, a workaround is put in place, but it is recommended that the WP expectDeprecated() method should be reevaluated in a future iteration.

Follow-up to [51559-51571].

Props jrf.
See #46149.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r51568 r51572  
    473473     */
    474474    public function expectDeprecated() {
    475         $annotations = $this->getAnnotations();
     475        if ( method_exists( $this, 'getAnnotations' ) ) {
     476            // PHPUnit < 9.5.0.
     477            $annotations = $this->getAnnotations();
     478        } else {
     479            // PHPUnit >= 9.5.0.
     480            $annotations = \PHPUnit\Util\Test::parseTestMethodAnnotations(
     481                static::class,
     482                $this->getName( false )
     483            );
     484        }
     485
    476486        foreach ( array( 'class', 'method' ) as $depth ) {
    477487            if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.