Ejemplo n.º 1
0
 public function testSetDefaultUserOptions()
 {
     $this->initializeManager();
     $context = \RequestContext::getMain();
     $reset = new \ScopedCallback([$context, 'setLanguage'], [$context->getLanguage()]);
     $context->setLanguage('de');
     $this->setMwGlobals('wgContLang', \Language::factory('zh'));
     $user = \User::newFromName(self::usernameForCreation());
     $user->addToDatabase();
     $oldToken = $user->getToken();
     $this->managerPriv->setDefaultUserOptions($user, false);
     $user->saveSettings();
     $this->assertNotEquals($oldToken, $user->getToken());
     $this->assertSame('zh', $user->getOption('language'));
     $this->assertSame('zh', $user->getOption('variant'));
     $user = \User::newFromName(self::usernameForCreation());
     $user->addToDatabase();
     $oldToken = $user->getToken();
     $this->managerPriv->setDefaultUserOptions($user, true);
     $user->saveSettings();
     $this->assertNotEquals($oldToken, $user->getToken());
     $this->assertSame('de', $user->getOption('language'));
     $this->assertSame('zh', $user->getOption('variant'));
     $this->setMwGlobals('wgContLang', \Language::factory('en'));
     $user = \User::newFromName(self::usernameForCreation());
     $user->addToDatabase();
     $oldToken = $user->getToken();
     $this->managerPriv->setDefaultUserOptions($user, true);
     $user->saveSettings();
     $this->assertNotEquals($oldToken, $user->getToken());
     $this->assertSame('de', $user->getOption('language'));
     $this->assertSame(null, $user->getOption('variant'));
 }