/**
  * @covers DBSiteStore::saveSites
  */
 public function testSaveSites()
 {
     $store = new DBSiteStore();
     $sites = array();
     $site = new Site();
     $site->setGlobalId('ertrywuutr');
     $site->setLanguageCode('en');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('sdfhxujgkfpth');
     $site->setLanguageCode('nl');
     $sites[] = $site;
     $this->assertTrue($store->saveSites($sites));
     $site = $store->getSite('ertrywuutr');
     $this->assertInstanceOf('Site', $site);
     $this->assertEquals('en', $site->getLanguageCode());
     $this->assertTrue(is_integer($site->getInternalId()));
     $this->assertTrue($site->getInternalId() >= 0);
     $site = $store->getSite('sdfhxujgkfpth');
     $this->assertInstanceOf('Site', $site);
     $this->assertEquals('nl', $site->getLanguageCode());
     $this->assertTrue(is_integer($site->getInternalId()));
     $this->assertTrue($site->getInternalId() >= 0);
 }
Exemplo n.º 2
0
 /**
  * Inserts sites into the database for the unit tests that need them.
  *
  * @since 0.1
  */
 public static function insertIntoDb()
 {
     $sitesTable = new DBSiteStore();
     $sitesTable->clear();
     $sitesTable->saveSites(TestSites::getSites());
 }
 /**
  * @covers DBSiteStore::getSites
  */
 public function testGetSitesDefaultOrder()
 {
     $store = new DBSiteStore();
     $siteB = new Site();
     $siteB->setGlobalId('B');
     $siteA = new Site();
     $siteA->setGlobalId('A');
     $store->saveSites(array($siteB, $siteA));
     $sites = $store->getSites();
     $siteIdentifiers = array();
     /** @var Site $site */
     foreach ($sites as $site) {
         $siteIdentifiers[] = $site->getGlobalId();
     }
     $this->assertSame(array('A', 'B'), $siteIdentifiers);
     // Note: SiteList::getGlobalIdentifiers uses an other internal state. Iteration must be
     // tested separately.
     $this->assertSame(array('A', 'B'), $sites->getGlobalIdentifiers());
 }