Ejemplo n.º 1
0
 /**
  * @since 1.21
  *
  * @return array
  */
 public static function getSites()
 {
     $sites = array();
     $site = new Site();
     $site->setGlobalId('foobar');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('enwiktionary');
     $site->setGroup('wiktionary');
     $site->setLanguageCode('en');
     $site->addNavigationId('enwiktionary');
     $site->setPath(MediaWikiSite::PATH_PAGE, "https://en.wiktionary.org/wiki/\$1");
     $site->setPath(MediaWikiSite::PATH_FILE, "https://en.wiktionary.org/w/\$1");
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('dewiktionary');
     $site->setGroup('wiktionary');
     $site->setLanguageCode('de');
     $site->addInterwikiId('dewiktionary');
     $site->addInterwikiId('wiktionaryde');
     $site->setPath(MediaWikiSite::PATH_PAGE, "https://de.wiktionary.org/wiki/\$1");
     $site->setPath(MediaWikiSite::PATH_FILE, "https://de.wiktionary.org/w/\$1");
     $sites[] = $site;
     $site = new Site();
     $site->setGlobalId('spam');
     $site->setGroup('spam');
     $site->setLanguageCode('en');
     $site->addNavigationId('spam');
     $site->addNavigationId('spamz');
     $site->addInterwikiId('spamzz');
     $site->setLinkPath("http://spamzz.test/testing/");
     $sites[] = $site;
     /**
      * Add at least one right-to-left language (current RTL languages in MediaWiki core are:
      * aeb, ar, arc, arz, azb, bcc, bqi, ckb, dv, en_rtl, fa, glk, he, khw, kk_arab, kk_cn,
      * ks_arab, ku_arab, lrc, mzn, pnb, ps, sd, ug_arab, ur, yi).
      */
     $languageCodes = array('de', 'en', 'fa', 'nl', 'nn', 'no', 'sr', 'sv');
     foreach ($languageCodes as $langCode) {
         $site = new MediaWikiSite();
         $site->setGlobalId($langCode . 'wiki');
         $site->setGroup('wikipedia');
         $site->setLanguageCode($langCode);
         $site->addInterwikiId($langCode);
         $site->addNavigationId($langCode);
         $site->setPath(MediaWikiSite::PATH_PAGE, "https://{$langCode}.wikipedia.org/wiki/\$1");
         $site->setPath(MediaWikiSite::PATH_FILE, "https://{$langCode}.wikipedia.org/w/\$1");
         $sites[] = $site;
     }
     return $sites;
 }
 /**
  * @covers HashSiteStore::saveSites
  */
 public function testSaveSites()
 {
     $store = new HashSiteStore();
     $sites = array();
     $site = new Site();
     $site->setGlobalId('enwiki');
     $site->setLanguageCode('en');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('eswiki');
     $site->setLanguageCode('es');
     $sites[] = $site;
     $this->assertCount(0, $store->getSites(), '0 sites in store');
     $store->saveSites($sites);
     $this->assertCount(2, $store->getSites(), 'Store has 2 sites');
     $this->assertTrue($store->getSites()->hasSite('enwiki'), 'Store has enwiki');
     $this->assertTrue($store->getSites()->hasSite('eswiki'), 'Store has eswiki');
 }
Ejemplo n.º 3
0
 /**
  * @covers CachingSiteStore::saveSites
  */
 public function testSaveSites()
 {
     $store = new CachingSiteStore(new HashSiteStore(), wfGetMainCache());
     $sites = [];
     $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());
     $site = $store->getSite('sdfhxujgkfpth');
     $this->assertInstanceOf('Site', $site);
     $this->assertEquals('nl', $site->getLanguageCode());
 }
 /**
  * @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);
 }
Ejemplo n.º 5
0
 /**
  * @dataProvider instanceProvider
  * @param Site $site
  * @covers Site::setLanguageCode
  */
 public function testSetLanguageCode(Site $site)
 {
     $site->setLanguageCode('en');
     $this->assertEquals('en', $site->getLanguageCode());
 }