MediaWiki  1.23.12
SiteListTest.php
Go to the documentation of this file.
1 <?php
2 
33 
38  public function siteListProvider() {
39  $sitesArrays = $this->siteArrayProvider();
40 
41  $listInstances = array();
42 
43  foreach ( $sitesArrays as $sitesArray ) {
44  $listInstances[] = new SiteList( $sitesArray[0] );
45  }
46 
47  return $this->arrayWrap( $listInstances );
48  }
49 
54  public function siteArrayProvider() {
55  $sites = TestSites::getSites();
56 
57  $siteArrays = array();
58 
59  $siteArrays[] = $sites;
60 
61  $siteArrays[] = array( array_shift( $sites ) );
62 
63  $siteArrays[] = array( array_shift( $sites ), array_shift( $sites ) );
64 
65  return $this->arrayWrap( $siteArrays );
66  }
67 
73  public function testIsEmpty( SiteList $sites ) {
74  $this->assertEquals( count( $sites ) === 0, $sites->isEmpty() );
75  }
76 
82  public function testGetSiteByGlobalId( SiteList $sites ) {
86  foreach ( $sites as $site ) {
87  $this->assertEquals( $site, $sites->getSite( $site->getGlobalId() ) );
88  }
89 
90  $this->assertTrue( true );
91  }
92 
98  public function testGetSiteByInternalId( $sites ) {
102  foreach ( $sites as $site ) {
103  if ( is_integer( $site->getInternalId() ) ) {
104  $this->assertEquals( $site, $sites->getSiteByInternalId( $site->getInternalId() ) );
105  }
106  }
107 
108  $this->assertTrue( true );
109  }
110 
116  public function testGetSiteByNavigationId( $sites ) {
120  foreach ( $sites as $site ) {
121  $ids = $site->getNavigationIds();
122  foreach ( $ids as $navId ) {
123  $this->assertEquals( $site, $sites->getSiteByNavigationId( $navId ) );
124  }
125  }
126 
127  $this->assertTrue( true );
128  }
129 
135  public function testHasGlobalId( $sites ) {
136  $this->assertFalse( $sites->hasSite( 'non-existing-global-id' ) );
137  $this->assertFalse( $sites->hasInternalId( 720101010 ) );
138 
139  if ( !$sites->isEmpty() ) {
143  foreach ( $sites as $site ) {
144  $this->assertTrue( $sites->hasSite( $site->getGlobalId() ) );
145  }
146  }
147  }
148 
154  public function testHasInternallId( $sites ) {
158  foreach ( $sites as $site ) {
159  if ( is_integer( $site->getInternalId() ) ) {
160  $this->assertTrue( $site, $sites->hasInternalId( $site->getInternalId() ) );
161  }
162  }
163 
164  $this->assertFalse( $sites->hasInternalId( -1 ) );
165  }
166 
172  public function testHasNavigationId( $sites ) {
176  foreach ( $sites as $site ) {
177  $ids = $site->getNavigationIds();
178  foreach ( $ids as $navId ) {
179  $this->assertTrue( $sites->hasNavigationId( $navId ) );
180  }
181  }
182 
183  $this->assertFalse( $sites->hasNavigationId( 'non-existing-navigation-id' ) );
184  }
185 
191  public function testGetGlobalIdentifiers( SiteList $sites ) {
192  $identifiers = $sites->getGlobalIdentifiers();
193 
194  $this->assertTrue( is_array( $identifiers ) );
195 
196  $expected = array();
197 
201  foreach ( $sites as $site ) {
202  $expected[] = $site->getGlobalId();
203  }
204 
205  $this->assertArrayEquals( $expected, $identifiers );
206  }
207 
217  public function testSerialization( SiteList $list ) {
218  $serialization = serialize( $list );
222  $copy = unserialize( $serialization );
223 
224  $this->assertArrayEquals( $list->getGlobalIdentifiers(), $copy->getGlobalIdentifiers() );
225 
229  foreach ( $list as $site ) {
230  $this->assertTrue( $copy->hasInternalId( $site->getInternalId() ) );
231 
232  foreach ( $site->getNavigationIds() as $navId ) {
233  $this->assertTrue(
234  $copy->hasNavigationId( $navId ),
235  'unserialized data expects nav id ' . $navId . ' for site ' . $site->getGlobalId()
236  );
237  }
238  }
239  }
240 }
SiteListTest\testIsEmpty
testIsEmpty(SiteList $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:73
MediaWikiTestCase\assertArrayEquals
assertArrayEquals(array $expected, array $actual, $ordered=false, $named=false)
Assert that two arrays are equal.
Definition: MediaWikiTestCase.php:764
SiteListTest\testGetGlobalIdentifiers
testGetGlobalIdentifiers(SiteList $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:191
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
SiteListTest
Definition: SiteListTest.php:32
TestSites\getSites
static getSites()
Definition: TestSites.php:39
SiteListTest\testSerialization
testSerialization(SiteList $list)
@dataProvider siteListProvider
Definition: SiteListTest.php:217
SiteListTest\testGetSiteByInternalId
testGetSiteByInternalId( $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:98
SiteListTest\testGetSiteByNavigationId
testGetSiteByNavigationId( $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:116
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
SiteList
Definition: SiteList.php:29
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MediaWikiTestCase\arrayWrap
arrayWrap(array $elements)
Utility method taking an array of elements and wrapping each element in it's own array.
Definition: MediaWikiTestCase.php:743
SiteList\isEmpty
isEmpty()
Returns if the list contains no sites.
Definition: SiteList.php:175
SiteListTest\testHasInternallId
testHasInternallId( $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:154
SiteListTest\siteListProvider
siteListProvider()
Returns instances of SiteList implementing objects.
Definition: SiteListTest.php:38
SiteListTest\testHasGlobalId
testHasGlobalId( $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:135
SiteListTest\testGetSiteByGlobalId
testGetSiteByGlobalId(SiteList $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:82
SiteList\getGlobalIdentifiers
getGlobalIdentifiers()
Returns all the global site identifiers.
Definition: SiteList.php:127
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
SiteList\getSite
getSite( $globalSiteId)
Returns the Site with the provided global site identifier.
Definition: SiteList.php:152
SiteListTest\testHasNavigationId
testHasNavigationId( $sites)
@dataProvider siteListProvider
Definition: SiteListTest.php:172
SiteListTest\siteArrayProvider
siteArrayProvider()
Returns arrays with instances of Site implementing objects.
Definition: SiteListTest.php:54