Readd after r72566 a phpunit.php so that globals are kept global.
authorPlatonides <platonides@users.mediawiki.org>
Sat, 9 Oct 2010 18:15:37 +0000 (18:15 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Sat, 9 Oct 2010 18:15:37 +0000 (18:15 +0000)
maintenance/tests/phpunit/Makefile
maintenance/tests/phpunit/bootstrap.php
maintenance/tests/phpunit/phpunit.php [new file with mode: 0755]

index d57ee5d..0784c4a 100644 (file)
@@ -3,7 +3,7 @@
 SHELL = /bin/sh
 CONFIG_FILE = $(shell pwd)/suite.xml
 FLAGS = 
-PU = phpunit --configuration ${CONFIG_FILE}
+PU = php phpunit.php --configuration ${CONFIG_FILE}
 
 all test: warning
 
index c278af1..e348b2c 100644 (file)
@@ -1,31 +1,18 @@
-<?php 
+<?php
 /**
  * Bootstrapping for MediaWiki PHPUnit tests
- * 
+ * This file is included by phpunit and is NOT in the global scope.
+ *
  * @file
  */
 
-/* Configuration */
-
-// This file is not included in the global scope, but rather within a function, so we must global anything we need to
-// have access to in the global scope explicitly
-global $wgCommandLineMode, $IP, $optionsWithArgs, $wgProfiler, $wgAutoloadClasses;
-
-// Evaluate the include path relative to this file
-$IP = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
-
-// Set a flag which can be used to detect when other scripts have been entered through this entry point or not
-define( 'MW_PHPUNIT_TEST', true );
-
-// Start up MediaWiki in command-line mode
-require_once( "$IP/maintenance/commandLine.inc" );
-
-// Assume UTC for testing purposes
-$wgLocaltimezone = 'UTC';
-
-// To prevent tests from failing with SQLite, we need to turn database caching off
-global $wgCaches;
-$wgCaches[CACHE_DB] = false;
+if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
+       echo <<<EOF
+You are running these tests directly from phpunit. You may not have all globals correctly set.
+Running phpunit.php instead is recommended.
+EOF;
+       require_once ( dirname( __FILE__ ) . "/phpunit.php" );
+}
 
 // Output a notice when running with older versions of PHPUnit
 if ( !version_compare( PHPUnit_Runner_Version::id(), "3.4.1", ">" ) ) {
@@ -74,3 +61,4 @@ abstract class MediaWikiTestSetup extends PHPUnit_Framework_TestCase {
                }
        }
 }
+
diff --git a/maintenance/tests/phpunit/phpunit.php b/maintenance/tests/phpunit/phpunit.php
new file mode 100755 (executable)
index 0000000..6fde611
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env php
+<?php
+/**
+ * Bootstrapping for MediaWiki PHPUnit tests
+ * 
+ * @file
+ */
+
+/* Configuration */
+
+// Evaluate the include path relative to this file
+$IP = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
+
+// Set a flag which can be used to detect when other scripts have been entered through this entry point or not
+define( 'MW_PHPUNIT_TEST', true );
+
+// Start up MediaWiki in command-line mode
+require_once( "$IP/maintenance/commandLine.inc" );
+
+// Assume UTC for testing purposes
+$wgLocaltimezone = 'UTC';
+
+// To prevent tests from failing with SQLite, we need to turn database caching off
+$wgCaches[CACHE_DB] = false;
+
+require_once "/usr/bin/phpunit";
+