Fixed phpunit exception test
authorYuri Astrakhan <yurik@wikimedia.org>
Mon, 16 Mar 2015 23:37:38 +0000 (02:37 +0300)
committerYuri Astrakhan <yurik@wikimedia.org>
Tue, 17 Mar 2015 00:01:28 +0000 (03:01 +0300)
phpunit has removed that class in
https://github.com/sebastianbergmann/phpunit/commit/f0322b6978bc2b6fd9a17f499950a4b023ef3db4
instead adding a dependency on "sebastian/comparator": "dev-master"
https://github.com/sebastianbergmann/comparator

The class name changed from PHPUnit_Framework_ComparisonFailure
to \SebastianBergmann\Comparator\ComparisonFailure\ComparisonFailure

Bug: T90880
Change-Id: I8988d0b07c00f54c8c8dd38a5e92a5736d88b163

tests/phpunit/includes/api/query/ApiQueryTestBase.php

index 1220bb4..e664173 100644 (file)
@@ -116,9 +116,16 @@ STR;
                        if ( is_array( $message ) ) {
                                $message = http_build_query( $message );
                        }
+
+                       // FIXME: once we migrate to phpunit 4.1+, hardcode ComparisonFailure exception use
+                       $compEx = 'SebastianBergmann\Comparator\ComparisonFailure';
+                       if ( !class_exists( $compEx ) ) {
+                               $compEx = 'PHPUnit_Framework_ComparisonFailure';
+                       }
+
                        throw new PHPUnit_Framework_ExpectationFailedException(
                                $e->getMessage() . "\nRequest: $message",
-                               new PHPUnit_Framework_ComparisonFailure(
+                               new $compEx(
                                        $exp,
                                        $result,
                                        print_r( $exp, true ),