From 9d78fc2c872daf0eed70a1d63a09cc5b34711d0f Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 14 Apr 2018 16:10:24 -0700 Subject: [PATCH] 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 --- tests/phpunit/PHPUnit4And6Compat.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 ); } -- 2.20.1