X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FPHPUnit4And6Compat.php;h=79ce634fab75ddc3b520cf75196d0f0398250d1c;hb=d7678fa45e949a5a5eaa369b45e48667a6132c07;hp=ac2c4f5a2629f8c90dfb0b15b0608648d9a69737;hpb=a175567e1e3e66a4b0468f492cc20271f9a7f116;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/PHPUnit4And6Compat.php b/tests/phpunit/PHPUnit4And6Compat.php index ac2c4f5a26..79ce634fab 100644 --- a/tests/phpunit/PHPUnit4And6Compat.php +++ b/tests/phpunit/PHPUnit4And6Compat.php @@ -29,8 +29,10 @@ trait PHPUnit4And6Compat { * is a temporary backwards-compatibility layer while we transition. */ public function setExpectedException( $name, $message = '', $code = null ) { - if ( is_callable( [ $this, 'expectException' ] ) ) { - $this->expectException( $name ); + if ( is_callable( 'parent::expectException' ) ) { + if ( $name !== null ) { + parent::expectException( $name ); + } if ( $message !== '' ) { $this->expectExceptionMessage( $message ); } @@ -42,6 +44,18 @@ trait PHPUnit4And6Compat { } } + /** + * Future-compatible layer for PHPUnit 4's setExpectedException. + */ + public function expectException( $exception ) { + if ( is_callable( 'parent::expectException' ) ) { + parent::expectException( $exception ); + return; + } + + parent::setExpectedException( $exception ); + } + /** * @see PHPUnit_Framework_TestCase::getMock *