X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fsite%2FDBSiteStoreTest.php;h=32dd7f282cef7063854781d545754d0539953a98;hb=e4af56a9fbafb368724f9fdbc6ae85f5aa1efc35;hp=48ef5243b9ef06a5a894b78b52dbd99946bd1e21;hpb=c175b53c0e4bf06a00345d15cd370258f41ba865;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/site/DBSiteStoreTest.php b/tests/phpunit/includes/site/DBSiteStoreTest.php index 48ef5243b9..32dd7f282c 100644 --- a/tests/phpunit/includes/site/DBSiteStoreTest.php +++ b/tests/phpunit/includes/site/DBSiteStoreTest.php @@ -31,6 +31,15 @@ */ class DBSiteStoreTest extends MediaWikiTestCase { + /** + * @return DBSiteStore + */ + private function newDBSiteStore() { + // NOTE: Use the real DB load balancer for now. Eventually, the test framework should + // provide a LoadBalancer that is safe to use in unit tests. + return new DBSiteStore( wfGetLB() ); + } + /** * @covers DBSiteStore::getSites */ @@ -38,7 +47,7 @@ class DBSiteStoreTest extends MediaWikiTestCase { $expectedSites = TestSites::getSites(); TestSites::insertIntoDb(); - $store = new DBSiteStore(); + $store = $this->newDBSiteStore(); $sites = $store->getSites(); @@ -62,9 +71,9 @@ class DBSiteStoreTest extends MediaWikiTestCase { * @covers DBSiteStore::saveSites */ public function testSaveSites() { - $store = new DBSiteStore(); + $store = $this->newDBSiteStore(); - $sites = array(); + $sites = []; $site = new Site(); $site->setGlobalId( 'ertrywuutr' ); @@ -95,8 +104,8 @@ class DBSiteStoreTest extends MediaWikiTestCase { * @covers DBSiteStore::reset */ public function testReset() { - $store1 = new DBSiteStore(); - $store2 = new DBSiteStore(); + $store1 = $this->newDBSiteStore(); + $store2 = $this->newDBSiteStore(); // initialize internal cache $this->assertGreaterThan( 0, $store1->getSites()->count() ); @@ -121,7 +130,7 @@ class DBSiteStoreTest extends MediaWikiTestCase { * @covers DBSiteStore::clear */ public function testClear() { - $store = new DBSiteStore(); + $store = $this->newDBSiteStore(); $this->assertTrue( $store->clear() ); $site = $store->getSite( 'enwiki' ); @@ -135,23 +144,23 @@ class DBSiteStoreTest extends MediaWikiTestCase { * @covers DBSiteStore::getSites */ public function testGetSitesDefaultOrder() { - $store = new DBSiteStore(); + $store = $this->newDBSiteStore(); $siteB = new Site(); $siteB->setGlobalId( 'B' ); $siteA = new Site(); $siteA->setGlobalId( 'A' ); - $store->saveSites( array( $siteB, $siteA ) ); + $store->saveSites( [ $siteB, $siteA ] ); $sites = $store->getSites(); - $siteIdentifiers = array(); + $siteIdentifiers = []; /** @var Site $site */ foreach ( $sites as $site ) { $siteIdentifiers[] = $site->getGlobalId(); } - $this->assertSame( array( 'A', 'B' ), $siteIdentifiers ); + $this->assertSame( [ 'A', 'B' ], $siteIdentifiers ); // Note: SiteList::getGlobalIdentifiers uses an other internal state. Iteration must be // tested separately. - $this->assertSame( array( 'A', 'B' ), $sites->getGlobalIdentifiers() ); + $this->assertSame( [ 'A', 'B' ], $sites->getGlobalIdentifiers() ); } }