From 45a0f997340ce7e03cba0d3e948a2429bfebc38c Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 3 Dec 2017 14:49:31 +0000 Subject: [PATCH] Allow PHPUnit 6 optionally in require-dev MediaWiki uses a back-compat layer to preserve most of the PHPUnit 4 runtime, so existing tests will continue to run fine with minimal modification. Once PHP < 7.0 support is dropped, we can drop PHPUnit 4 support, and adapt tests to use PHPUnit 6 features directly. Bug: T177132 Depends-On: I884b240307e3fcad253aa64eeae9944ed4eb7d50 Change-Id: I497712c7693d137be197a69873baa58383ce9646 --- composer.json | 2 +- tests/phan/config.php | 4 ++++ tests/phan/stubs/phpunit4.php | 11 +++++++++++ tests/phpunit/phpunit.php | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/phan/stubs/phpunit4.php diff --git a/composer.json b/composer.json index 9cb4ba9202..321a941353 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/tests/phan/config.php b/tests/phan/config.php index 84132b9682..71ebd6f4d0 100644 --- a/tests/phan/config.php +++ b/tests/phan/config.php @@ -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 index 0000000000..e5e88e6bab --- /dev/null +++ b/tests/phan/stubs/phpunit4.php @@ -0,0 +1,11 @@ +hasOption( 'with-phpunitclass' ) ) { $phpUnitClass = $this->getOption( 'with-phpunitclass' ); -- 2.20.1