Example #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);
 }
Example #2
0
 public function setUp()
 {
     parent::setUp();
     $conf = new SiteConfiguration();
     $conf->settings = ['wgServer' => ['enwiki' => 'http://en.example.org', 'ruwiki' => '//ru.example.org'], 'wgArticlePath' => ['enwiki' => '/w/$1', 'ruwiki' => '/wiki/$1']];
     $conf->suffixes = ['wiki'];
     $this->setMwGlobals(['wgConf' => $conf]);
     TestSites::insertIntoDb();
 }
 public function setUp()
 {
     parent::setUp();
     static $hasSites = false;
     if (!$hasSites) {
         TestSites::insertIntoDb();
         $hasSites = true;
     }
 }
 /**
  * @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;
     }
 }
 /**
  * @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()));
         }
     }
 }
Example #8
0
 public function setUp()
 {
     parent::setUp();
     TestSites::insertIntoDb();
 }
Example #9
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());
 }
Example #10
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
 }
Example #11
0
 public function instanceProvider()
 {
     return $this->arrayWrap(TestSites::getSites());
 }
 /**
  * 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());
 }
Example #13
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());
 }