40 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
53 $sites = $store->getSites();
60 foreach ( $sites
as $site ) {
64 foreach ( $expectedSites
as $site ) {
65 if ( $site->getGlobalId() !==
null ) {
66 $this->assertTrue( $sites->hasSite( $site->getGlobalId() ) );
80 $site->setGlobalId(
'ertrywuutr' );
81 $site->setLanguageCode(
'en' );
85 $site->setGlobalId(
'sdfhxujgkfpth' );
86 $site->setLanguageCode(
'nl' );
89 $this->assertTrue( $store->saveSites( $sites ) );
91 $site = $store->getSite(
'ertrywuutr' );
93 $this->assertEquals(
'en', $site->getLanguageCode() );
94 $this->assertTrue( is_int( $site->getInternalId() ) );
95 $this->assertTrue( $site->getInternalId() >= 0 );
97 $site = $store->getSite(
'sdfhxujgkfpth' );
99 $this->assertEquals(
'nl', $site->getLanguageCode() );
100 $this->assertTrue( is_int( $site->getInternalId() ) );
101 $this->assertTrue( $site->getInternalId() >= 0 );
112 $this->assertGreaterThan( 0, $store1->getSites()->count() );
113 $this->assertGreaterThan( 0, $store2->getSites()->count() );
117 $this->assertTrue( $store1->clear() );
120 $this->assertNotNull( $store2->getSite(
'enwiki' ) );
126 $site = $store2->getSite(
'enwiki' );
127 $this->assertNull( $site );
135 $this->assertTrue( $store->clear() );
137 $site = $store->getSite(
'enwiki' );
138 $this->assertNull( $site );
140 $sites = $store->getSites();
141 $this->assertEquals( 0, $sites->count() );
150 $siteB->setGlobalId(
'B' );
152 $siteA->setGlobalId(
'A' );
153 $store->saveSites( [ $siteB, $siteA ] );
155 $sites = $store->getSites();
156 $siteIdentifiers = [];
158 foreach ( $sites
as $site ) {
159 $siteIdentifiers[] = $site->getGlobalId();
161 $this->assertSame( [
'A',
'B' ], $siteIdentifiers );
165 $this->assertSame( [
'A',
'B' ], $sites->getGlobalIdentifiers() );