/**
  * @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());
 }
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::clear
  */
 public function testClear()
 {
     $store = new DBSiteStore();
     $this->assertTrue($store->clear());
     $site = $store->getSite('enwiki');
     $this->assertNull($site);
     $sites = $store->getSites();
     $this->assertEquals(0, $sites->count());
 }