3 abstract class ApiSetup
extends PHPUnit_Framework_TestCase
{
4 protected static $userName;
5 protected static $passWord;
6 protected static $user;
7 protected static $apiUrl;
10 global $wgServerName, $wgServer, $wgContLang, $wgAuth, $wgScriptPath,
11 $wgScriptExtension, $wgMemc, $wgRequest;
13 self
::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension;
15 $wgMemc = new FakeMemCachedClient
;
16 $wgContLang = Language
::factory( 'en' );
17 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
18 $wgRequest = new FauxRequest(array());
22 static function setupUser() {
23 if ( self
::$user == NULL ) {
24 self
::$userName = "Useruser";
25 self
::$passWord = User
::randomPassword();
27 self
::$user = User
::newFromName(self
::$userName);
28 if ( !self
::$user->getID() ) {
29 self
::$user = User
::createNew(self
::$userName, array(
30 "email" => "test@example.com",
31 "real_name" => "Test User"));
33 self
::$user->setPassword(self
::$passWord);
34 self
::$user->saveSettings();