tests: Support passing null to setExpectedException() in compat layer
authorKunal Mehta <legoktm@member.fsf.org>
Sat, 14 Apr 2018 23:10:24 +0000 (16:10 -0700)
committerLegoktm <legoktm@member.fsf.org>
Sun, 15 Apr 2018 08:10:35 +0000 (08:10 +0000)
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

index ac2c4f5..672ab4a 100644 (file)
@@ -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 );
                        }