/**
  * Setup a fresh set of global users for each test.
  * Note: MediaWikiTestCase::resetDB() will delete all tables between
  * test runs, so no explicite tearDown() is needed.
  */
 protected function setUp()
 {
     parent::setUp();
     $u = new CentralAuthTestUser('GlobalUser', 'GUP@ssword', array('gu_id' => '1001'), array(array(self::safeWfWikiID(), 'primary'), array('enwiki', 'primary'), array('dewiki', 'login'), array('metawiki', 'password')));
     $u->save($this->db);
     // Locked but not hidden Global account
     $u = new CentralAuthTestUser('GlobalLockedUser', 'GLUP@ssword', array('gu_id' => '1003', 'gu_locked' => 1, 'gu_hidden' => CentralAuthUser::HIDDEN_NONE, 'gu_email' => 'testlocked@localhost', 'gu_home_db' => 'metawiki'), array(array('metawiki', 'primary'), array(self::safeWfWikiID(), 'password')));
     $u->save($this->db);
     // Global account that isn't attached on this wiki, and doesn't conflict
     $u = new CentralAuthTestUser('GlobalUnattachedUser', 'GUUP@ssword', array('gu_id' => '1004', 'gu_email' => 'testunattached@localhost', 'gu_home_db' => 'metawiki'), array(array('metawiki', 'primary')), false);
     $u->save($this->db);
     // Global unattached account with conflicting local user account
     $u = new CentralAuthTestUser('GlobalConflictUser', 'GCUP@ssword', array('gu_id' => '1005', 'gu_email' => 'testconflict@localhost', 'gu_home_db' => 'metawiki'), array(array('metawiki', 'primary')));
     $u->save($this->db);
     $user = User::newFromName('GlobalConflictUser');
     if ($user->idForName() == 0) {
         $user->addToDatabase();
         $user->setPassword($this->password);
         $user->saveSettings();
     }
     // Local only account
     $user = User::newFromName('AnotherNewUser');
     if ($user->idForName() == 0) {
         $user->addToDatabase();
         $user->setPassword('ANUP@ssword');
         $user->saveSettings();
     }
     // Global user who was renamed when migrated
     $u = new CentralAuthTestUser('GlobalUser~' . str_replace('_', '-', self::safeWfWikiID()), 'GURP@ssword', array('gu_id' => '1006'), array(array(self::safeWfWikiID(), 'primary')));
     $u->save($this->db);
 }
 /**
  * Setup a fresh set of global users for each test.
  * Note: MediaWikiTestCase::resetDB() will delete all tables between
  * test runs, so no explicite tearDown() is needed.
  */
 protected function setUp()
 {
     parent::setUp();
     $u = new CentralAuthTestUser('GlobalUser', 'GUP@ssword', array('gu_id' => '1001'), array(array(wfWikiID(), 'primary'), array('enwiki', 'primary'), array('dewiki', 'login'), array('metawiki', 'password')));
     $u->save($this->db);
     $u = new CentralAuthTestUser('GlobalLockedUser', 'GLUP@ssword', array('gu_id' => '1003', 'gu_locked' => 1, 'gu_hidden' => CentralAuthUser::HIDDEN_NONE, 'gu_email' => 'testlocked@localhost', 'gu_home_db' => 'metawiki'), array(array('metawiki', 'primary')));
     $u->save($this->db);
 }
 /**
  * Setup the centralauth tables in the current db, so we don't have
  * to worry about rights on another database. The first time it's called
  * we have to set the DB prefix ourselves, and reset it back to the original
  * so that CloneDatabase will work. On subsequent runs, the prefix is already
  * setup for us.
  */
 public static function setUpBeforeClass()
 {
     global $wgCentralAuthDatabase;
     parent::setUpBeforeClass();
     if (is_null(self::$centralAuthDatabase)) {
         self::$centralAuthDatabase = $wgCentralAuthDatabase;
     }
     $wgCentralAuthDatabase = false;
     // use the current wiki db
     $db = wfGetDB(DB_MASTER);
     if ($db->tablePrefix() !== MediaWikiTestCase::DB_PREFIX) {
         $originalPrefix = $db->tablePrefix();
         $db->tablePrefix(MediaWikiTestCase::DB_PREFIX);
         if (!$db->tableExists('globaluser')) {
             $db->sourceFile(__DIR__ . '/../../central-auth.sql');
         }
         $db->tablePrefix($originalPrefix);
     } else {
         $db->sourceFile(__DIR__ . '/../../central-auth.sql');
     }
 }