WordPress.org

Make WordPress Core

Changeset 40539


Ignore:
Timestamp:
04/23/2017 11:45:46 AM (14 months ago)
Author:
johnbillion
Message:

Build/Test Tools: Move the setExpectedException() method into the WP_Ajax_UnitTestCase class to avoid a fatal error when PHPUnit 3.6 is in use.

This needs more investigation but it gets the test suite on PHP 5.2 passing again.

See #39822

Location:
trunk/tests/phpunit/includes
Files:
2 edited

Legend:

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

    r38168 r40539  
    201201            $this->_last_response = $buffer;
    202202    }
     203
     204    /**
     205     * PHPUnit 6+ compatibility shim.
     206     *
     207     * @param mixed      $exception
     208     * @param string     $message
     209     * @param int|string $code
     210     */
     211    public function setExpectedException( $exception, $message = '', $code = null ) {
     212        if ( is_callable( 'parent::setExpectedException' ) ) {
     213            parent::setExpectedException( $exception, $message, $code );
     214        } else {
     215            $this->expectException( $exception );
     216            if ( '' !== $message ) {
     217                $this->expectExceptionMessage( $message );
     218            }
     219            if ( null !== $code ) {
     220                $this->expectExceptionCode( $code );
     221            }
     222        }
     223    }
    203224}
  • trunk/tests/phpunit/includes/testcase.php

    r40536 r40539  
    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 ( is_callable( 'parent::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         }
    437416    }
    438417
Note: See TracChangeset for help on using the changeset viewer.