Bug 7264 - Magic word to give Page Title as if pipe-trick performed on it {{pipetrick:}}
[lhc/web/wiklou.git] / maintenance / tests / MediaWikiAPI_Setup.php
1 <?php
2
3 abstract class MediaWikiAPI_Setup extends PHPUnit_Framework_TestCase {
4 protected static $userName;
5 protected static $passWord;
6 protected static $user;
7 protected static $apiUrl;
8
9 function setup() {
10 global $wgServerName, $wgServer, $wgContLang, $wgAuth, $wgScriptPath,
11 $wgScriptExtension, $wgMemc;
12
13 if($wgServerName == "localhost" || $wgServer == "http://localhost") {
14 $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
15 'be set in LocalSettings.php');
16 }
17 self::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension;
18
19 $wgMemc = new FakeMemCachedClient;
20 $wgContLang = Language::factory( 'en' );
21 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
22 self::setupUser();
23 }
24
25 static function setupUser() {
26 if ( self::$user == NULL ) {
27 self::$userName = "Useruser";
28 self::$passWord = User::randomPassword();
29
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);
38 }
39 self::$user->saveSettings();
40 }
41 }
42 }