Test cases working with “make tap” but not just “phpunit” right now.
[mediawiki.git] / maintenance / tests / ApiSetup.php
blob991dba3ee326579a51851ec41ac4a11722b4a722
1 <?php
3 abstract class ApiSetup extends PHPUnit_Framework_TestCase {
4 protected static $userName;
5 protected static $passWord;
6 protected static $user;
7 protected static $apiUrl;
9 function setup() {
10 global $wgServerName, $wgServer, $wgContLang, $wgAuth, $wgScriptPath,
11 $wgScriptExtension, $wgMemc;
13 if($wgServerName == "localhost" || $wgServer == "http://localhost") {
14 $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
15 'be set in LocalSettings.php');
17 self::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension;
19 $wgMemc = new FakeMemCachedClient;
20 $wgContLang = Language::factory( 'en' );
21 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
22 self::setupUser();
25 static function setupUser() {
26 if ( self::$user == NULL ) {
27 self::$userName = "Useruser";
28 self::$passWord = User::randomPassword();
30 self::$user = User::newFromName(self::$userName);
31 if ( !self::$user->getID() ) {
32 self::$user = User::createNew(self::$userName, array(
33 "password" => self::$passWord,
34 "email" => "test@example.com",
35 "real_name" => "Test User"));
36 } else {
37 self::$user->setPassword(self::$passWord);
39 self::$user->saveSettings();