42 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
55 $sites = $store->getSites();
62 foreach ( $sites
as $site ) {
66 foreach ( $expectedSites
as $site ) {
67 if ( $site->getGlobalId() !== null ) {
68 $this->assertTrue( $sites->hasSite( $site->getGlobalId() ) );
82 $site->setGlobalId(
'ertrywuutr' );
83 $site->setLanguageCode(
'en' );
87 $site->setGlobalId(
'sdfhxujgkfpth' );
88 $site->setLanguageCode(
'nl' );
91 $this->assertTrue( $store->saveSites( $sites ) );
93 $site = $store->getSite(
'ertrywuutr' );
95 $this->assertEquals(
'en', $site->getLanguageCode() );
96 $this->assertTrue( is_int( $site->getInternalId() ) );
97 $this->assertTrue( $site->getInternalId() >= 0 );
99 $site = $store->getSite(
'sdfhxujgkfpth' );
101 $this->assertEquals(
'nl', $site->getLanguageCode() );
102 $this->assertTrue( is_int( $site->getInternalId() ) );
103 $this->assertTrue( $site->getInternalId() >= 0 );
114 $this->assertGreaterThan( 0, $store1->getSites()->count() );
115 $this->assertGreaterThan( 0, $store2->getSites()->count() );
119 $this->assertTrue( $store1->clear() );
122 $this->assertNotNull( $store2->getSite(
'enwiki' ) );
128 $site = $store2->getSite(
'enwiki' );
129 $this->assertNull( $site );
137 $this->assertTrue( $store->clear() );
139 $site = $store->getSite(
'enwiki' );
140 $this->assertNull( $site );
142 $sites = $store->getSites();
143 $this->assertEquals( 0, $sites->count() );
152 $siteB->setGlobalId(
'B' );
154 $siteA->setGlobalId(
'A' );
155 $store->saveSites( [ $siteB, $siteA ] );
157 $sites = $store->getSites();
158 $siteIdentifiers = [];
160 foreach ( $sites
as $site ) {
161 $siteIdentifiers[] = $site->getGlobalId();
163 $this->assertSame( [
'A',
'B' ], $siteIdentifiers );
167 $this->assertSame( [
'A',
'B' ], $sites->getGlobalIdentifiers() );