follow-up r61355
[lhc/web/wiklou.git] / maintenance / tests / ApiSetup.php
1 <?php
2
3 abstract class ApiSetup 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, $wgRequest;
12
13 self::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension;
14
15 $wgMemc = new FakeMemCachedClient;
16 $wgContLang = Language::factory( 'en' );
17 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
18 $wgRequest = new FauxRequest(array());
19 self::setupUser();
20 }
21
22 static function setupUser() {
23 if ( self::$user == NULL ) {
24 self::$userName = "Useruser";
25 self::$passWord = User::randomPassword();
26
27 self::$user = User::newFromName(self::$userName);
28 if ( !self::$user->getID() ) {
29 self::$user = User::createNew(self::$userName, array(
30 "password" => self::$passWord,
31 "email" => "test@example.com",
32 "real_name" => "Test User"));
33 } else {
34 self::$user->setPassword(self::$passWord);
35 }
36 self::$user->saveSettings();
37 }
38 }
39 }