protected function tearDown()
 {
     global $wgHooks;
     $wgHooks['GetPreferences'] = $this->mOldGetPreferencesHooks;
     $this->mOldGetPreferencesHooks = false;
     parent::tearDown();
 }
 public function setUp()
 {
     parent::setUp();
     self::$notifyCallCounter = 0;
     self::$mockRecentChange = self::getMock('RecentChange');
     $this->setContentLang('qqx');
 }
Example #3
0
 protected function setUp()
 {
     parent::setUp();
     $dbw = wfGetDB(DB_MASTER);
     $dbw->replace('interwiki', ['iw_prefix'], ['iw_prefix' => 'linksupdatetest', 'iw_url' => 'http://testing.com/wiki/$1', 'iw_api' => 'http://testing.com/w/api.php', 'iw_local' => 0, 'iw_trans' => 0, 'iw_wikiid' => 'linksupdatetest']);
     $this->setMwGlobals('wgRCWatchCategoryMembership', true);
 }
 protected function setUp()
 {
     parent::setUp();
     // Avoid 'GetHumanTimestamp' hook and others
     $this->setMwGlobals('wgHooks', array());
     RequestContext::getMain()->setLanguage(Language::factory('en'));
 }
Example #5
0
 protected function setUp()
 {
     parent::setUp();
     $this->initMessagesHref();
     $this->skin = new SkinTemplate();
     $this->skin->getContext()->setLanguage(Language::factory('en'));
 }
Example #6
0
 protected function setUp()
 {
     parent::setUp();
     if (!extension_loaded('intl')) {
         $this->markTestSkipped('These tests require intl extension');
     }
 }
 protected function setUp()
 {
     parent::setUp();
     $langObj = Language::factory('en');
     $localZone = 'UTC';
     $localOffset = date('Z') / 60;
     $this->setMwGlobals(array('wgMemc' => new EmptyBagOStuff(), 'wgContLang' => $langObj, 'wgLang' => $langObj, 'wgLocaltimezone' => $localZone, 'wgLocalTZoffset' => $localOffset, 'wgNamespaceProtection' => array(NS_MEDIAWIKI => 'editinterface')));
     $this->userName = '******';
     $this->altUserName = '******';
     date_default_timezone_set($localZone);
     $this->title = Title::makeTitle(NS_MAIN, "Main Page");
     if (!isset($this->userUser) || !$this->userUser instanceof User) {
         $this->userUser = User::newFromName($this->userName);
         if (!$this->userUser->getID()) {
             $this->userUser = User::createNew($this->userName, array("email" => "*****@*****.**", "real_name" => "Test User"));
             $this->userUser->load();
         }
         $this->altUser = User::newFromName($this->altUserName);
         if (!$this->altUser->getID()) {
             $this->altUser = User::createNew($this->altUserName, array("email" => "*****@*****.**", "real_name" => "Test User Alt"));
             $this->altUser->load();
         }
         $this->anonUser = User::newFromId(0);
         $this->user = $this->userUser;
     }
 }
 function setUp()
 {
     global $wgDefaultUserOptions;
     parent::setUp();
     //ensure the correct default gender
     $wgDefaultUserOptions['gender'] = 'unknown';
 }
 function tearDown()
 {
     global $wgMemc;
     unset($wgMemc);
     unset($this->lc);
     unset($this->lang);
     parent::tearDown();
 }
Example #10
0
 public function setUp()
 {
     parent::setUp();
     $conf = new SiteConfiguration();
     $conf->settings = array('wgServer' => array('enwiki' => 'http://en.example.org', 'ruwiki' => '//ru.example.org'), 'wgArticlePath' => array('enwiki' => '/w/$1', 'ruwiki' => '/wiki/$1'));
     $conf->suffixes = array('wiki');
     $this->setMwGlobals(array('wgConf' => $conf));
 }
 public function tearDown()
 {
     global $wgContLang, $wgLang, $wgLanguageCode;
     $wgLang = self::$oldLang;
     $wgContLang = self::$oldContLang;
     $wgLanguageCode = $wgContLang->getCode();
     self::$oldContLang = self::$oldLang = null;
 }
 public function setUp()
 {
     parent::setUp();
     $user = User::newFromName('UserThatExists');
     if (!$user->getId()) {
         $user->addToDatabase();
     }
 }
 public function teardown()
 {
     global $wgHooks;
     // restore hooks that force custom rendering
     if ($this->savedContentGetParserOutput !== null) {
         $wgHooks['ContentGetParserOutput'] = $this->savedContentGetParserOutput;
     }
     parent::teardown();
 }
 protected function tearDown()
 {
     global $wgContLang;
     parent::tearDown();
     MWNamespace::getCanonicalNamespaces(true);
     # reset namespace cache
     $wgContLang->resetNamespaces();
     # reset namespace cache
 }
 public function tearDown()
 {
     global $wgHooks;
     if ($this->mOldGetPreferencesHooks !== false) {
         $wgHooks['GetPreferences'] = $this->mOldGetPreferencesHooks;
         $this->mOldGetPreferencesHooks = false;
     }
     parent::tearDown();
 }
Example #16
0
 public function setUp()
 {
     parent::setUp();
     $conf = new SiteConfiguration();
     $conf->settings = ['wgServer' => ['enwiki' => 'http://en.example.org', 'ruwiki' => '//ru.example.org'], 'wgArticlePath' => ['enwiki' => '/w/$1', 'ruwiki' => '/wiki/$1']];
     $conf->suffixes = ['wiki'];
     $this->setMwGlobals(['wgConf' => $conf]);
     TestSites::insertIntoDb();
 }
 protected function setUp()
 {
     parent::setUp();
     if (!$this->isWikitextNS(NS_MAIN)) {
         $this->markTestSkipped('Main namespace does not support wikitext.');
     }
     // Avoid special pages from extensions interferring with the tests
     $this->setMwGlobals('wgSpecialPages', array());
 }
 /**
  * Default set up function.
  *
  * Clears $wgUser, and reports errors from addDBData to PHPUnit
  */
 protected function setUp()
 {
     parent::setUp();
     // Check if any Exception is stored for rethrowing from addDBData
     // @see self::exceptionFromAddDBData
     if ($this->exceptionFromAddDBData !== null) {
         throw $this->exceptionFromAddDBData;
     }
     $this->setMwGlobals('wgUser', new User());
 }
 protected function tearDown()
 {
     // Avoid leaking session over tests
     if (session_id() != '') {
         global $wgUser;
         $wgUser->logout();
         session_destroy();
     }
     parent::tearDown();
 }
 protected function setUp()
 {
     global $wgServer;
     parent::setUp();
     self::$apiUrl = $wgServer . wfScript('api');
     ApiQueryInfo::resetTokenCache();
     // tokens are invalid because we cleared the session
     self::$users = array('sysop' => new TestUser('Apitestsysop', 'Api Test Sysop', '*****@*****.**', array('sysop')), 'uploader' => new TestUser('Apitestuser', 'Api Test User', '*****@*****.**', array()));
     $this->setMwGlobals(array('wgMemc' => new EmptyBagOStuff(), 'wgAuth' => new StubObject('wgAuth', 'AuthPlugin'), 'wgRequest' => new FauxRequest(array()), 'wgUser' => self::$users['sysop']->user));
     $this->apiContext = new ApiTestContext();
 }
 /**
  * Default set up function.
  *
  * Clears $wgUser, and reports errors from addDBData to PHPUnit
  */
 public function setUp()
 {
     global $wgUser;
     parent::setUp();
     // Check if any Exception is stored for rethrowing from addDBData
     // @see self::exceptionFromAddDBData
     if ($this->exceptionFromAddDBData !== null) {
         throw $this->exceptionFromAddDBData;
     }
     $wgUser = new User();
 }
Example #22
0
 protected function setUp()
 {
     parent::setUp();
     // Anon user
     $user = new User();
     $user->setName('127.0.0.1');
     $this->setMwGlobals(array('wgUser' => $user, 'wgTextModelsToParse' => array(CONTENT_MODEL_WIKITEXT, CONTENT_MODEL_CSS, CONTENT_MODEL_JAVASCRIPT), 'wgUseTidy' => false, 'wgAlwaysUseTidy' => false));
     $this->context = new RequestContext(new FauxRequest());
     $this->context->setTitle(Title::newFromText('Test'));
     $this->context->setUser($user);
 }
 protected function setUp()
 {
     parent::setUp();
     global $wgHooks;
     $this->setMwGlobals(array('wgHooks' => $wgHooks, 'wgTranslateDocumentationLanguageCode' => 'qqq', 'wgTranslateTranslationServices' => array(), 'wgTranslateMessageNamespaces' => array(NS_MEDIAWIKI)));
     $wgHooks['TranslatePostInitGroups'] = array(array($this, 'getTestGroups'));
     $mg = MessageGroups::singleton();
     $mg->setCache(wfGetCache('hash'));
     $mg->recache();
     MessageIndex::setInstance(new HashMessageIndex());
     MessageIndex::singleton()->rebuild();
 }
Example #24
0
 function setUp()
 {
     global $wgContLang, $wgAuth, $wgMemc, $wgRequest, $wgUser, $wgServer;
     parent::setUp();
     self::$apiUrl = $wgServer . wfScript('api');
     $wgMemc = new EmptyBagOStuff();
     $wgContLang = Language::factory('en');
     $wgAuth = new StubObject('wgAuth', 'AuthPlugin');
     $wgRequest = new FauxRequest(array());
     self::$users = array('sysop' => new ApiTestUser('Apitestsysop', 'Api Test Sysop', '*****@*****.**', array('sysop')), 'uploader' => new ApiTestUser('Apitestuser', 'Api Test User', '*****@*****.**', array()));
     $wgUser = self::$users['sysop']->user;
 }
 protected function setUp()
 {
     parent::setUp();
     $this->mUserMock = $this->getMockBuilder('User')->disableOriginalConstructor()->getMock();
     // Create a new context
     $this->mContext = new DerivativeContext(new RequestContext());
     $this->mContext->setUser($this->mUserMock);
     $main = new ApiMain($this->mContext);
     // Empty session
     $this->mSession = array();
     $this->mTested = new ApiOptions($main, 'options');
 }
Example #26
0
 protected function tearDown()
 {
     global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
     parent::tearDown();
     unset($wgExtraNamespaces[12312]);
     unset($wgExtraNamespaces[12313]);
     unset($wgNamespaceContentModels[12312]);
     unset($wgContentHandlers['DUMMY']);
     MWNamespace::getCanonicalNamespaces(true);
     # reset namespace cache
     $wgContLang->resetNamespaces();
     # reset namespace cache
 }
Example #27
0
 protected function setUp()
 {
     global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
     parent::setUp();
     $this->setMwGlobals(['wgExtraNamespaces' => $wgExtraNamespaces, 'wgNamespaceContentModels' => $wgNamespaceContentModels, 'wgContentHandlers' => $wgContentHandlers, 'wgContLang' => $wgContLang]);
     $wgExtraNamespaces[12312] = 'Dummy';
     $wgExtraNamespaces[12313] = 'Dummy_talk';
     $wgNamespaceContentModels[12312] = "testing";
     $wgContentHandlers["testing"] = 'DummyContentHandlerForTesting';
     MWNamespace::getCanonicalNamespaces(true);
     # reset namespace cache
     $wgContLang->resetNamespaces();
     # reset namespace cache
 }
 protected function tearDown()
 {
     foreach ($this->pages_to_delete as $p) {
         /* @var $p WikiPage */
         try {
             if ($p->exists()) {
                 $p->doDeleteArticle("testing done.");
             }
         } catch (MWException $ex) {
             // fail silently
         }
     }
     parent::tearDown();
 }
 protected function setUp()
 {
     parent::setUp();
     $this->mUserMock = $this->getMockBuilder('User')->disableOriginalConstructor()->getMock();
     // Set up groups and rights
     $this->mUserMock->expects($this->any())->method('getEffectiveGroups')->will($this->returnValue(array('*', 'user')));
     $this->mUserMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true));
     // Set up callback for User::getOptionKinds
     $this->mUserMock->expects($this->any())->method('getOptionKinds')->will($this->returnCallback(array($this, 'getOptionKinds')));
     // Create a new context
     $this->mContext = new DerivativeContext(new RequestContext());
     $this->mContext->getContext()->setTitle(Title::newFromText('Test'));
     $this->mContext->setUser($this->mUserMock);
     $main = new ApiMain($this->mContext);
     // Empty session
     $this->mSession = array();
     $this->mTested = new ApiOptions($main, 'options');
     $this->mergeMwGlobalArrayValue('wgHooks', array('GetPreferences' => array(array($this, 'hookGetPreferences'))));
 }
 protected function setUp()
 {
     parent::setUp();
     $langObj = Language::factory('en');
     $localZone = 'UTC';
     $localOffset = date('Z') / 60;
     $this->setMwGlobals(array('wgMemc' => new EmptyBagOStuff(), 'wgContLang' => $langObj, 'wgLanguageCode' => 'en', 'wgLang' => $langObj, 'wgLocaltimezone' => $localZone, 'wgLocalTZoffset' => $localOffset, 'wgNamespaceProtection' => array(NS_MEDIAWIKI => 'editinterface')));
     // Without this testUserBlock will use a non-English context on non-English MediaWiki
     // installations (because of how Title::checkUserBlock is implemented) and fail.
     RequestContext::resetMain();
     $this->userName = '******';
     $this->altUserName = '******';
     date_default_timezone_set($localZone);
     $this->title = Title::makeTitle(NS_MAIN, "Main Page");
     if (!isset($this->userUser) || !$this->userUser instanceof User) {
         $this->userUser = User::newFromName($this->userName);
         if (!$this->userUser->getID()) {
             $this->userUser = User::createNew($this->userName, array("email" => "*****@*****.**", "real_name" => "Test User"));
             $this->userUser->load();
         }
         $this->altUser = User::newFromName($this->altUserName);
         if (!$this->altUser->getID()) {
             $this->altUser = User::createNew($this->altUserName, array("email" => "*****@*****.**", "real_name" => "Test User Alt"));
             $this->altUser->load();
         }
         $this->anonUser = User::newFromId(0);
         $this->user = $this->userUser;
     }
 }