Make WordPress Core


Ignore:
Timestamp:
06/05/2017 10:41:02 AM (8 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Fix PHP 5.2 compatibility for grandchild methods which expect exceptions to be raised.

This is due to is_callable( 'parent::setExpectedException' ) not being supported on PHP 5.2 when the method being checked only exists on the grandparent class.

See #39822

Merges [40872] and [40873] to the 4.7 branch.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/tests/phpunit/includes/testcase.php

    r40388 r40876  
    414414    public function setExpectedIncorrectUsage( $doing_it_wrong ) {
    415415        array_push( $this->expected_doing_it_wrong, $doing_it_wrong );
     416    }
     417
     418    /**
     419     * PHPUnit 6+ compatibility shim.
     420     *
     421     * @param mixed      $exception
     422     * @param string     $message
     423     * @param int|string $code
     424     */
     425    public function setExpectedException( $exception, $message = '', $code = null ) {
     426        if ( method_exists( 'PHPUnit_Framework_TestCase', 'setExpectedException' ) ) {
     427            parent::setExpectedException( $exception, $message, $code );
     428        } else {
     429            $this->expectException( $exception );
     430            if ( '' !== $message ) {
     431                $this->expectExceptionMessage( $message );
     432            }
     433            if ( null !== $code ) {
     434                $this->expectExceptionCode( $code );
     435            }
     436        }
    416437    }
    417438
Note: See TracChangeset for help on using the changeset viewer.