Use an autoloader for the tests, following the ideas from r72858.
authorPlatonides <platonides@users.mediawiki.org>
Sat, 1 Jan 2011 22:04:14 +0000 (22:04 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Sat, 1 Jan 2011 22:04:14 +0000 (22:04 +0000)
The SeleniumTestConstants class was added in r79437

tests/TestsAutoLoader.php [new file with mode: 0644]
tests/phpunit/includes/api/ApiTest.php
tests/phpunit/includes/api/ApiUploadTest.php
tests/phpunit/phpunit.php

diff --git a/tests/TestsAutoLoader.php b/tests/TestsAutoLoader.php
new file mode 100644 (file)
index 0000000..13198f8
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+global $wgAutoloadClasses;
+$testFolder = dirname( __FILE__ );
+
+$wgAutoloadClasses += array(
+       'MediaWikiTestCase' => "$testFolder/phpunit/MediaWikiTestCase.php",
+       'MediaWikiPHPUnitCommand' => "$testFolder/phpunit/MediaWikiPHPUnitCommand.php",
+       'ApiTestSetup' => "$testFolder/phpunit/includes/api/ApiSetup.php",
+       'RandomImageGenerator' => "$testFolder/phpunit/includes/api/RandomImageGenerator.php",
+       'SeleniumTestConstants' => "$testFolder/selenium/SeleniumTestConstants.php",
+);
+
index a7ae903..9d38852 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 
-require_once( dirname( __FILE__ ) . '/ApiSetup.php' );
-
 class MockApi extends ApiBase {
        public function execute() { }
        public function getVersion() { }
index 87abbb9..b33a5d9 100644 (file)
@@ -17,9 +17,6 @@
 // TODO: refactor into several files
 // TODO: port the other Upload tests, and other API tests to this framework
 
-require_once( dirname( __FILE__ ) . '/RandomImageGenerator.php' );
-require_once( dirname( __FILE__ ) . '/../../../../includes/User.php' );
-
 /* Wraps the user object, so we can also retain full access to properties like password if we log in via the API */
 class ApiTestUser {
        public $username;
@@ -130,7 +127,7 @@ abstract class ApiTestCase extends MediaWikiTestCase {
                        // add edit token to fake session
                        $session['wsEditToken'] = $session['wsToken'];
                        // add token to request parameters
-                       $params['token'] = md5( $session['wsToken'] ) . EDIT_TOKEN_SUFFIX;
+                       $params['token'] = md5( $session['wsToken'] ) . User::EDIT_TOKEN_SUFFIX;
                        return $this->doApiRequest( $params, $session );
                } else {
                        throw new Exception( "request data not in right format" );
index d70f753..e89c442 100755 (executable)
@@ -35,7 +35,6 @@ if( version_compare( PHPUnit_Runner_Version::id(), '3.5.0', '>=' ) ) {
        require_once( 'PHPUnit/TextUI/Command.php' );
 }
 
-require_once( "$IP/tests/phpunit/MediaWikiPHPUnitCommand.php" );
-require_once( "$IP/tests/phpunit/MediaWikiTestCase.php" );
+require_once( "$IP/tests/TestsAutoLoader.php" );
 MediaWikiPHPUnitCommand::main();