MediaWiki  1.23.15
SiteSQLStoreTest.php
Go to the documentation of this file.
1 <?php
2 
34 
38  public function testGetSites() {
39  $expectedSites = TestSites::getSites();
41 
42  $store = SiteSQLStore::newInstance();
43 
44  $sites = $store->getSites();
45 
46  $this->assertInstanceOf( 'SiteList', $sites );
47 
51  foreach ( $sites as $site ) {
52  $this->assertInstanceOf( 'Site', $site );
53  }
54 
55  foreach ( $expectedSites as $site ) {
56  if ( $site->getGlobalId() !== null ) {
57  $this->assertTrue( $sites->hasSite( $site->getGlobalId() ) );
58  }
59  }
60  }
61 
65  public function testSaveSites() {
66  $store = SiteSQLStore::newInstance();
67 
68  $sites = array();
69 
70  $site = new Site();
71  $site->setGlobalId( 'ertrywuutr' );
72  $site->setLanguageCode( 'en' );
73  $sites[] = $site;
74 
75  $site = new MediaWikiSite();
76  $site->setGlobalId( 'sdfhxujgkfpth' );
77  $site->setLanguageCode( 'nl' );
78  $sites[] = $site;
79 
80  $this->assertTrue( $store->saveSites( $sites ) );
81 
82  $site = $store->getSite( 'ertrywuutr' );
83  $this->assertInstanceOf( 'Site', $site );
84  $this->assertEquals( 'en', $site->getLanguageCode() );
85  $this->assertTrue( is_integer( $site->getInternalId() ) );
86  $this->assertTrue( $site->getInternalId() >= 0 );
87 
88  $site = $store->getSite( 'sdfhxujgkfpth' );
89  $this->assertInstanceOf( 'Site', $site );
90  $this->assertEquals( 'nl', $site->getLanguageCode() );
91  $this->assertTrue( is_integer( $site->getInternalId() ) );
92  $this->assertTrue( $site->getInternalId() >= 0 );
93  }
94 
98  public function testReset() {
99  $store1 = SiteSQLStore::newInstance();
100  $store2 = SiteSQLStore::newInstance();
101 
102  // initialize internal cache
103  $this->assertGreaterThan( 0, $store1->getSites()->count() );
104  $this->assertGreaterThan( 0, $store2->getSites()->count() );
105 
106  // Clear actual data. Will purge the external cache and reset the internal
107  // cache in $store1, but not the internal cache in store2.
108  $this->assertTrue( $store1->clear() );
109 
110  // sanity check: $store2 should have a stale cache now
111  $this->assertNotNull( $store2->getSite( 'enwiki' ) );
112 
113  // purge cache
114  $store2->reset();
115 
116  // ...now the internal cache of $store2 should be updated and thus empty.
117  $site = $store2->getSite( 'enwiki' );
118  $this->assertNull( $site );
119  }
120 
124  public function testClear() {
125  $store = SiteSQLStore::newInstance();
126  $this->assertTrue( $store->clear() );
127 
128  $site = $store->getSite( 'enwiki' );
129  $this->assertNull( $site );
130 
131  $sites = $store->getSites();
132  $this->assertEquals( 0, $sites->count() );
133  }
134 }
SiteSQLStoreTest\testSaveSites
testSaveSites()
@covers SiteSQLStore::saveSites
Definition: SiteSQLStoreTest.php:65
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
TestSites\getSites
static getSites()
Definition: TestSites.php:39
SiteSQLStoreTest\testClear
testClear()
@covers SiteSQLStore::clear
Definition: SiteSQLStoreTest.php:124
SiteSQLStoreTest
Definition: SiteSQLStoreTest.php:33
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Site
Definition: Site.php:29
SiteSQLStoreTest\testGetSites
testGetSites()
@covers SiteSQLStore::getSites
Definition: SiteSQLStoreTest.php:38
SiteSQLStore\newInstance
static newInstance(ORMTable $sitesTable=null)
Definition: SiteSQLStore.php:58
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
MediaWikiSite
Class representing a MediaWiki site.
Definition: MediaWikiSite.php:35
TestSites\insertIntoDb
static insertIntoDb()
Inserts sites into the database for the unit tests that need them.
Definition: TestSites.php:95
SiteSQLStoreTest\testReset
testReset()
@covers SiteSQLStore::reset
Definition: SiteSQLStoreTest.php:98