4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
25 * @author Katie Filbert < aude.wiki@gmail.com >
27 class HashSiteStoreTest
extends MediaWikiTestCase
{
30 * @covers HashSiteStore::getSites
32 public function testGetSites() {
35 foreach ( TestSites
::getSites() as $testSite ) {
36 $siteId = $testSite->getGlobalId();
37 $expectedSites[$siteId] = $testSite;
40 $siteStore = new HashSiteStore( $expectedSites );
42 $this->assertEquals( new SiteList( $expectedSites ), $siteStore->getSites() );
46 * @covers HashSiteStore::saveSite
47 * @covers HashSiteStore::getSite
49 public function testSaveSite() {
50 $store = new HashSiteStore();
53 $site->setGlobalId( 'dewiki' );
55 $this->assertCount( 0, $store->getSites(), '0 sites in store' );
57 $store->saveSite( $site );
59 $this->assertCount( 1, $store->getSites(), 'Store has 1 sites' );
60 $this->assertEquals( $site, $store->getSite( 'dewiki' ), 'Store has dewiki' );
64 * @covers HashSiteStore::saveSites
66 public function testSaveSites() {
67 $store = new HashSiteStore();
72 $site->setGlobalId( 'enwiki' );
73 $site->setLanguageCode( 'en' );
76 $site = new MediaWikiSite();
77 $site->setGlobalId( 'eswiki' );
78 $site->setLanguageCode( 'es' );
81 $this->assertCount( 0, $store->getSites(), '0 sites in store' );
83 $store->saveSites( $sites );
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' );
91 * @covers HashSiteStore::clear
93 public function testClear() {
94 $store = new HashSiteStore();
97 $site->setGlobalId( 'arwiki' );
98 $store->saveSite( $site );
100 $this->assertCount( 1, $store->getSites(), '1 site in store' );
103 $this->assertCount( 0, $store->getSites(), '0 sites in store' );