Merge "Allow PHPUnit 6 optionally in require-dev"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 13 Apr 2018 17:59:57 +0000 (17:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 13 Apr 2018 17:59:57 +0000 (17:59 +0000)
composer.json
tests/phan/config.php
tests/phan/stubs/phpunit4.php [new file with mode: 0644]
tests/phpunit/phpunit.php

index 9cb4ba9..321a941 100644 (file)
@@ -59,7 +59,7 @@
                "monolog/monolog": "~1.22.1",
                "nikic/php-parser": "3.1.3",
                "nmred/kafka-php": "0.1.5",
-               "phpunit/phpunit": "4.8.36",
+               "phpunit/phpunit": "4.8.36 || ^6.5",
                "psy/psysh": "0.8.11",
                "wikimedia/avro": "1.8.0",
                "wikimedia/testing-access-wrapper": "~1.0",
index 84132b9..71ebd6f 100644 (file)
@@ -38,6 +38,10 @@ return [
                function_exists( 'tideways_enable' ) ? [] : [ 'tests/phan/stubs/tideways.php' ],
                class_exists( PEAR::class ) ? [] : [ 'tests/phan/stubs/mail.php' ],
                class_exists( Memcached::class ) ? [] : [ 'tests/phan/stubs/memcached.php' ],
+               // Per composer.json, PHPUnit 6 is used for PHP 7.0+, PHPUnit 4 otherwise.
+               // Load the interface for the version of PHPUnit that isn't installed.
+               // Phan only supports PHP 7.0+ (and not HHVM), so we only need to stub PHPUnit 4.
+               class_exists( PHPUnit_TextUI_Command::class ) ? [] : [ 'tests/phan/stubs/phpunit4.php' ],
                [
                        'maintenance/7zip.inc',
                        'maintenance/backup.inc',
diff --git a/tests/phan/stubs/phpunit4.php b/tests/phan/stubs/phpunit4.php
new file mode 100644 (file)
index 0000000..e5e88e6
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * Some old classes from PHPUnit 4 that MediaWiki (conditionally) references.
+ *
+ * phpcs:ignoreFile
+ */
+
+class PHPUnit_TextUI_Command {
+
+}
index fa249b2..7cf042d 100755 (executable)
@@ -80,7 +80,7 @@ class PHPUnitMaintClass extends Maintenance {
                                [ '--configuration', $IP . '/tests/phpunit/suite.xml' ] );
                }
 
-               $phpUnitClass = 'PHPUnit_TextUI_Command';
+               $phpUnitClass = PHPUnit_TextUI_Command::class;
 
                if ( $this->hasOption( 'with-phpunitclass' ) ) {
                        $phpUnitClass = $this->getOption( 'with-phpunitclass' );