From: Kunal Mehta Date: Sat, 14 Apr 2018 23:10:24 +0000 (-0700) Subject: tests: Support passing null to setExpectedException() in compat layer X-Git-Tag: 1.31.0-rc.0~66^2 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=9d78fc2c872daf0eed70a1d63a09cc5b34711d0f;p=lhc%2Fweb%2Fwiklou.git tests: Support passing null to setExpectedException() in compat layer PHPUnit 4's setExpectedException() accepted null for the exception class name to indicate that no exception would be thrown. PHPUnit 6's expectException() is stricter and only allows strings. Change-Id: I8c8783faec808a8f111af2ee533f5c61feccf099 --- diff --git a/tests/phpunit/PHPUnit4And6Compat.php b/tests/phpunit/PHPUnit4And6Compat.php index ac2c4f5a26..672ab4a4d6 100644 --- a/tests/phpunit/PHPUnit4And6Compat.php +++ b/tests/phpunit/PHPUnit4And6Compat.php @@ -30,7 +30,9 @@ trait PHPUnit4And6Compat { */ public function setExpectedException( $name, $message = '', $code = null ) { if ( is_callable( [ $this, 'expectException' ] ) ) { - $this->expectException( $name ); + if ( $name !== null ) { + $this->expectException( $name ); + } if ( $message !== '' ) { $this->expectExceptionMessage( $message ); }