summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/site
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /tests/phpunit/includes/site
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'tests/phpunit/includes/site')
-rw-r--r--tests/phpunit/includes/site/CachingSiteStoreTest.php8
-rw-r--r--tests/phpunit/includes/site/DBSiteStoreTest.php24
-rw-r--r--tests/phpunit/includes/site/HashSiteStoreTest.php2
-rw-r--r--tests/phpunit/includes/site/SiteExporterTest.php4
-rw-r--r--tests/phpunit/includes/site/SiteImporterTest.php12
5 files changed, 37 insertions, 13 deletions
diff --git a/tests/phpunit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/includes/site/CachingSiteStoreTest.php
index d0a79803..4305ceb9 100644
--- a/tests/phpunit/includes/site/CachingSiteStoreTest.php
+++ b/tests/phpunit/includes/site/CachingSiteStoreTest.php
@@ -96,17 +96,17 @@ class CachingSiteStoreTest extends MediaWikiTestCase {
->getMock();
// php 5.3 compatibility!
- $self = $this;
+ $that = $this;
$dbSiteStore->expects( $this->any() )
->method( 'getSite' )
- ->will( $this->returnValue( $self->getTestSite() ) );
+ ->will( $this->returnValue( $that->getTestSite() ) );
$dbSiteStore->expects( $this->any() )
->method( 'getSites' )
- ->will( $this->returnCallback( function() use( $self ) {
+ ->will( $this->returnCallback( function() use ( $that ) {
$siteList = new SiteList();
- $siteList->setSite( $self->getTestSite() );
+ $siteList->setSite( $that->getTestSite() );
return $siteList;
} ) );
diff --git a/tests/phpunit/includes/site/DBSiteStoreTest.php b/tests/phpunit/includes/site/DBSiteStoreTest.php
index 673ba54d..48ef5243 100644
--- a/tests/phpunit/includes/site/DBSiteStoreTest.php
+++ b/tests/phpunit/includes/site/DBSiteStoreTest.php
@@ -130,4 +130,28 @@ class DBSiteStoreTest extends MediaWikiTestCase {
$sites = $store->getSites();
$this->assertEquals( 0, $sites->count() );
}
+
+ /**
+ * @covers DBSiteStore::getSites
+ */
+ public function testGetSitesDefaultOrder() {
+ $store = new DBSiteStore();
+ $siteB = new Site();
+ $siteB->setGlobalId( 'B' );
+ $siteA = new Site();
+ $siteA->setGlobalId( 'A' );
+ $store->saveSites( array( $siteB, $siteA ) );
+
+ $sites = $store->getSites();
+ $siteIdentifiers = array();
+ /** @var Site $site */
+ foreach ( $sites as $site ) {
+ $siteIdentifiers[] = $site->getGlobalId();
+ }
+ $this->assertSame( array( 'A', 'B' ), $siteIdentifiers );
+
+ // Note: SiteList::getGlobalIdentifiers uses an other internal state. Iteration must be
+ // tested separately.
+ $this->assertSame( array( 'A', 'B' ), $sites->getGlobalIdentifiers() );
+ }
}
diff --git a/tests/phpunit/includes/site/HashSiteStoreTest.php b/tests/phpunit/includes/site/HashSiteStoreTest.php
index 49a96338..bebc0936 100644
--- a/tests/phpunit/includes/site/HashSiteStoreTest.php
+++ b/tests/phpunit/includes/site/HashSiteStoreTest.php
@@ -32,7 +32,7 @@ class HashSiteStoreTest extends MediaWikiTestCase {
public function testGetSites() {
$expectedSites = array();
- foreach( TestSites::getSites() as $testSite ) {
+ foreach ( TestSites::getSites() as $testSite ) {
$siteId = $testSite->getGlobalId();
$expectedSites[$siteId] = $testSite;
}
diff --git a/tests/phpunit/includes/site/SiteExporterTest.php b/tests/phpunit/includes/site/SiteExporterTest.php
index 19dd0aa1..7be19ef9 100644
--- a/tests/phpunit/includes/site/SiteExporterTest.php
+++ b/tests/phpunit/includes/site/SiteExporterTest.php
@@ -53,7 +53,7 @@ class SiteExporterTest extends PHPUnit_Framework_TestCase {
$exporter->exportSites( array( $foo, $acme ) );
fseek( $tmp, 0 );
- $xml = fread( $tmp, 16*1024 );
+ $xml = fread( $tmp, 16 * 1024 );
$this->assertContains( '<sites ', $xml );
$this->assertContains( '<site>', $xml );
@@ -133,7 +133,7 @@ class SiteExporterTest extends PHPUnit_Framework_TestCase {
$exporter->exportSites( $sites );
fseek( $tmp, 0 );
- $xml = fread( $tmp, 16*1024 );
+ $xml = fread( $tmp, 16 * 1024 );
$actualSites = new SiteList();
$store = $this->newSiteStore( $actualSites );
diff --git a/tests/phpunit/includes/site/SiteImporterTest.php b/tests/phpunit/includes/site/SiteImporterTest.php
index cb0316ab..b11b1a9f 100644
--- a/tests/phpunit/includes/site/SiteImporterTest.php
+++ b/tests/phpunit/includes/site/SiteImporterTest.php
@@ -34,11 +34,11 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase {
private function newSiteImporter( array $expectedSites, $errorCount ) {
$store = $this->getMock( 'SiteStore' );
- $self = $this;
+ $that = $this;
$store->expects( $this->once() )
->method( 'saveSites' )
- ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites, $self ) {
- $self->assertSitesEqual( $expectedSites, $sites );
+ ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites, $that ) {
+ $that->assertSitesEqual( $expectedSites, $sites );
} ) );
$store->expects( $this->any() )
@@ -141,12 +141,12 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase {
/**
* @dataProvider provideImportFromXML
*/
- public function testImportFromXML( $xml, array $expectedSites, $errorCount = 0 ) {
+ public function testImportFromXML( $xml, array $expectedSites, $errorCount = 0 ) {
$importer = $this->newSiteImporter( $expectedSites, $errorCount );
$importer->importFromXML( $xml );
}
- public function testImportFromXML_malformed() {
+ public function testImportFromXML_malformed() {
$this->setExpectedException( 'Exception' );
$store = $this->getMock( 'SiteStore' );
@@ -154,7 +154,7 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase {
$importer->importFromXML( 'THIS IS NOT XML' );
}
- public function testImportFromFile() {
+ public function testImportFromFile() {
$foo = Site::newForType( Site::TYPE_UNKNOWN );
$foo->setGlobalId( 'Foo' );