X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FPHPUnit4And6Compat.php;h=1ef0c916839d689f63fef00eddc8b3f21e9a424c;hb=33415e2930b8e583fe81ec026608c0af523f7afe;hp=672ab4a4d650d6c0bf79b6488cd7be27d5564fd3;hpb=c29357e7e81b631668c8bd3ccd4b805701380c63;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/PHPUnit4And6Compat.php b/tests/phpunit/PHPUnit4And6Compat.php index 672ab4a4d6..1ef0c91683 100644 --- a/tests/phpunit/PHPUnit4And6Compat.php +++ b/tests/phpunit/PHPUnit4And6Compat.php @@ -29,9 +29,9 @@ trait PHPUnit4And6Compat { * is a temporary backwards-compatibility layer while we transition. */ public function setExpectedException( $name, $message = '', $code = null ) { - if ( is_callable( [ $this, 'expectException' ] ) ) { + if ( is_callable( 'parent::expectException' ) ) { if ( $name !== null ) { - $this->expectException( $name ); + parent::expectException( $name ); } if ( $message !== '' ) { $this->expectExceptionMessage( $message ); @@ -44,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 * @@ -118,4 +130,18 @@ trait PHPUnit4And6Compat { // ->disallowMockingUnknownTypes() ->getMock(); } + + /** + * Marks the current test as risky. This + * is a forward port of the markAsRisky function that + * was introduced in PHPUnit 5.7.6. + */ + public function markAsRisky() { + if ( is_callable( 'parent::markAsRisky' ) ) { + return parent::markAsRisky(); + } + + // "risky" tests are not supported in phpunit 4, so just ignore + } + }