MediaWiki REL1_32
HashSiteStoreTest.php
Go to the documentation of this file.
1<?php
2
28
32 public function testGetSites() {
33 $expectedSites = [];
34
35 foreach ( TestSites::getSites() as $testSite ) {
36 $siteId = $testSite->getGlobalId();
37 $expectedSites[$siteId] = $testSite;
38 }
39
40 $siteStore = new HashSiteStore( $expectedSites );
41
42 $this->assertEquals( new SiteList( $expectedSites ), $siteStore->getSites() );
43 }
44
49 public function testSaveSite() {
50 $store = new HashSiteStore();
51
52 $site = new Site();
53 $site->setGlobalId( 'dewiki' );
54
55 $this->assertCount( 0, $store->getSites(), '0 sites in store' );
56
57 $store->saveSite( $site );
58
59 $this->assertCount( 1, $store->getSites(), 'Store has 1 sites' );
60 $this->assertEquals( $site, $store->getSite( 'dewiki' ), 'Store has dewiki' );
61 }
62
66 public function testSaveSites() {
67 $store = new HashSiteStore();
68
69 $sites = [];
70
71 $site = new Site();
72 $site->setGlobalId( 'enwiki' );
73 $site->setLanguageCode( 'en' );
74 $sites[] = $site;
75
76 $site = new MediaWikiSite();
77 $site->setGlobalId( 'eswiki' );
78 $site->setLanguageCode( 'es' );
79 $sites[] = $site;
80
81 $this->assertCount( 0, $store->getSites(), '0 sites in store' );
82
83 $store->saveSites( $sites );
84
85 $this->assertCount( 2, $store->getSites(), 'Store has 2 sites' );
86 $this->assertTrue( $store->getSites()->hasSite( 'enwiki' ), 'Store has enwiki' );
87 $this->assertTrue( $store->getSites()->hasSite( 'eswiki' ), 'Store has eswiki' );
88 }
89
93 public function testClear() {
94 $store = new HashSiteStore();
95
96 $site = new Site();
97 $site->setGlobalId( 'arwiki' );
98 $store->saveSite( $site );
99
100 $this->assertCount( 1, $store->getSites(), '1 site in store' );
101
102 $store->clear();
103 $this->assertCount( 0, $store->getSites(), '0 sites in store' );
104 }
105}
testClear()
HashSiteStore::clear.
testGetSites()
HashSiteStore::getSites.
testSaveSites()
HashSiteStore::saveSites.
testSaveSite()
HashSiteStore::saveSite HashSiteStore::getSite.
In-memory SiteStore implementation, storing sites in an associative array.
Class representing a MediaWiki site.
Definition Site.php:29
static getSites()
Definition TestSites.php:36