jenkins-bot has submitted this change and it was merged.

Change subject: Add --with-phpunitclass arg to phpunit.php
......................................................................


Add --with-phpunitclass arg to phpunit.php

This would allow to easily use stuff like
https://github.com/fiunchinho/phpunit-randomizer.

Change-Id: I28e8b1d261de0395366b18465a0adc4d7c4fde4a
---
M tests/phpunit/phpunit.php
1 file changed, 27 insertions(+), 2 deletions(-)

Approvals:
  Daniel Kinzler: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php
index 02d1a1d..4d060e4 100755
--- a/tests/phpunit/phpunit.php
+++ b/tests/phpunit/phpunit.php
@@ -10,6 +10,8 @@
 // through this entry point or not.
 define( 'MW_PHPUNIT_TEST', true );
 
+$wgPhpUnitClass = 'PHPUnit_TextUI_Command';
+
 // Start up MediaWiki in command-line mode
 require_once dirname( dirname( __DIR__ ) ) . "/maintenance/Maintenance.php";
 
@@ -29,6 +31,12 @@
 
        public function __construct() {
                parent::__construct();
+               $this->addOption(
+                       'with-phpunitclass',
+                       'Class name of the PHPUnit entry point to use',
+                       false,
+                       true
+               );
                $this->addOption(
                        'debug-tests',
                        'Log testing activity to the PHPUnitCommand log 
channel.',
@@ -151,6 +159,18 @@
                                [ '--configuration', $IP . 
'/tests/phpunit/suite.xml' ] );
                }
 
+               if ( $this->hasOption( 'with-phpunitclass' ) ) {
+                       global $wgPhpUnitClass;
+                       $wgPhpUnitClass = $this->getOption( 'with-phpunitclass' 
);
+
+                       # Cleanup $args array so the option and its value do not
+                       # pollute PHPUnit
+                       $key = array_search( '--with-phpunitclass', 
$_SERVER['argv'] );
+                       unset( $_SERVER['argv'][$key] ); // the option
+                       unset( $_SERVER['argv'][$key + 1] ); // its value
+                       $_SERVER['argv'] = array_values( $_SERVER['argv'] );
+               }
+
                $key = array_search( '--debug-tests', $_SERVER['argv'] );
                if ( $key !== false && array_search( '--printer', 
$_SERVER['argv'] ) === false ) {
                        unset( $_SERVER['argv'][$key] );
@@ -202,9 +222,14 @@
 $maintClass = 'PHPUnitMaintClass';
 require RUN_MAINTENANCE_IF_MAIN;
 
-if ( !class_exists( 'PHPUnit_TextUI_Command' ) ) {
+if ( !class_exists( 'PHPUnit_Framework_TestCase' ) ) {
        echo "PHPUnit not found. Please install it and other dev dependencies by
 running `composer install` in MediaWiki root directory.\n";
+       exit( 1 );
+}
+if ( !class_exists( $wgPhpUnitClass ) ) {
+       echo "PHPUnit entry point '" . $wgPhpUnitClass . "' not found. Please 
make sure you installed
+the containing component and check the spelling of the class name.\n";
        exit( 1 );
 }
 
@@ -212,4 +237,4 @@
        'Using HHVM ' . HHVM_VERSION . ' (' . PHP_VERSION . ")\n" :
        'Using PHP ' . PHP_VERSION . "\n";
 
-PHPUnit_TextUI_Command::main();
+$wgPhpUnitClass::main();

-- 
To view, visit https://gerrit.wikimedia.org/r/277975
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I28e8b1d261de0395366b18465a0adc4d7c4fde4a
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Adrian Heine <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to