Ejemplo n.º 1
0
 /**
  * Returns arrays with instances of Site implementing objects.
  * @return array
  */
 public function siteArrayProvider()
 {
     $sites = TestSites::getSites();
     $siteArrays = array();
     $siteArrays[] = $sites;
     $siteArrays[] = array(array_shift($sites));
     $siteArrays[] = array(array_shift($sites), array_shift($sites));
     return $this->arrayWrap($siteArrays);
 }
 /**
  * @covers HashSiteStore::getSites
  */
 public function testGetSites()
 {
     $expectedSites = array();
     foreach (TestSites::getSites() as $testSite) {
         $siteId = $testSite->getGlobalId();
         $expectedSites[$siteId] = $testSite;
     }
     $siteStore = new HashSiteStore($expectedSites);
     $this->assertEquals(new SiteList($expectedSites), $siteStore->getSites());
 }
 protected function setUp()
 {
     parent::setUp();
     static $isSetup = false;
     \ApiTestCase::$users['wbeditor'] = new \TestUser('Apitesteditor', 'Api Test Editor', '*****@*****.**', array('wbeditor'));
     $this->setMwGlobals('wgUser', self::$users['wbeditor']->getUser());
     if (!$isSetup) {
         // TODO: Remove me once everything that needs this is overridden.
         $sitesTable = WikibaseRepo::getDefaultInstance()->getSiteStore();
         $sitesTable->clear();
         $sitesTable->saveSites(\TestSites::getSites());
         $isSetup = true;
     }
 }
Ejemplo n.º 4
0
 /**
  * @covers CachingSiteStore::getSites
  */
 public function testGetSites()
 {
     $testSites = TestSites::getSites();
     $store = new CachingSiteStore($this->getHashSiteStore($testSites), wfGetMainCache());
     $sites = $store->getSites();
     $this->assertInstanceOf('SiteList', $sites);
     /**
      * @var Site $site
      */
     foreach ($sites as $site) {
         $this->assertInstanceOf('Site', $site);
     }
     foreach ($testSites as $site) {
         if ($site->getGlobalId() !== null) {
             $this->assertTrue($sites->hasSite($site->getGlobalId()));
         }
     }
 }
 /**
  * @covers DBSiteStore::getSites
  */
 public function testGetSites()
 {
     $expectedSites = TestSites::getSites();
     TestSites::insertIntoDb();
     $store = new DBSiteStore();
     $sites = $store->getSites();
     $this->assertInstanceOf('SiteList', $sites);
     /**
      * @var Site $site
      */
     foreach ($sites as $site) {
         $this->assertInstanceOf('Site', $site);
     }
     foreach ($expectedSites as $site) {
         if ($site->getGlobalId() !== null) {
             $this->assertTrue($sites->hasSite($site->getGlobalId()));
         }
     }
 }
Ejemplo n.º 6
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());
 }
Ejemplo n.º 7
0
 /**
  * Inserts sites into the database for the unit tests that need them.
  *
  * @since 0.1
  */
 public static function insertIntoDb()
 {
     $dbw = wfGetDB(DB_MASTER);
     $dbw->begin(__METHOD__);
     $dbw->delete('sites', '*', __METHOD__);
     $dbw->delete('site_identifiers', '*', __METHOD__);
     /**
      * @var Site $site
      */
     foreach (TestSites::getSites() as $site) {
         $site->save();
     }
     $dbw->commit(__METHOD__);
     Sites::singleton()->getSites(false);
     // re-cache
 }
Ejemplo n.º 8
0
 public function instanceProvider()
 {
     return $this->arrayWrap(TestSites::getSites());
 }
Ejemplo n.º 9
0
 /**
  * Inserts sites into the database for the unit tests that need them.
  *
  * @since 0.1
  */
 public static function insertIntoDb()
 {
     $sitesTable = SiteSQLStore::newInstance();
     $sitesTable->clear();
     $sitesTable->saveSites(TestSites::getSites());
 }
Ejemplo n.º 10
0
 /**
  * Inserts sites into the database for the unit tests that need them.
  *
  * @since 0.1
  */
 public static function insertIntoDb()
 {
     $sitesTable = \MediaWiki\MediaWikiServices::getInstance()->getSiteStore();
     $sitesTable->clear();
     $sitesTable->saveSites(TestSites::getSites());
 }