diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
commit | a2190ac74dd4d7080b12bab90e552d7aa81209ef (patch) | |
tree | 8b31f38de9882d18df54cf8d9e0de74167a094eb /tests/phpunit/includes/site | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'tests/phpunit/includes/site')
-rw-r--r-- | tests/phpunit/includes/site/CachingSiteStoreTest.php | 8 | ||||
-rw-r--r-- | tests/phpunit/includes/site/DBSiteStoreTest.php | 24 | ||||
-rw-r--r-- | tests/phpunit/includes/site/HashSiteStoreTest.php | 2 | ||||
-rw-r--r-- | tests/phpunit/includes/site/SiteExporterTest.php | 4 | ||||
-rw-r--r-- | tests/phpunit/includes/site/SiteImporterTest.php | 12 |
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' ); |