X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FStorage%2FNameTableStoreTest.php;h=1517964471e9659fde5b3574f3d80575204e2ac2;hp=b5b2e0dd45399a87826c7abd7d0a070dafb7650d;hb=74d04edec385aa86ee01943b9a27475d79f74e78;hpb=07beacf802a2d1688e67114ce8aaf6fc7da90d05 diff --git a/tests/phpunit/includes/Storage/NameTableStoreTest.php b/tests/phpunit/includes/Storage/NameTableStoreTest.php index b5b2e0dd45..1517964471 100644 --- a/tests/phpunit/includes/Storage/NameTableStoreTest.php +++ b/tests/phpunit/includes/Storage/NameTableStoreTest.php @@ -26,6 +26,10 @@ class NameTableStoreTest extends MediaWikiTestCase { parent::setUp(); } + protected function addCoreDBData() { + // The default implementation causes the slot_roles to already have content. Skip that. + } + private function populateTable( $values ) { $insertValues = []; foreach ( $values as $name ) { @@ -139,6 +143,9 @@ class NameTableStoreTest extends MediaWikiTestCase { $name, $expectedId ) { + // Make sure the table is empty! + $this->truncateTable( 'slot_roles' ); + $this->populateTable( $existingValues ); $store = $this->getNameTableSqlStore( $cacheBag, (int)$needsInsert, $selectCalls ); @@ -266,6 +273,21 @@ class NameTableStoreTest extends MediaWikiTestCase { $this->assertSame( $expected, TestingAccessWrapper::newFromObject( $store )->tableCache ); } + public function testReloadMap() { + $this->populateTable( [ 'foo' ] ); + $store = $this->getNameTableSqlStore( new HashBagOStuff(), 0, 2 ); + + // force load + $this->assertCount( 1, $store->getMap() ); + + // add more stuff to the table, so the cache gets out of sync + $this->populateTable( [ 'bar' ] ); + + $expected = [ 1 => 'foo', 2 => 'bar' ]; + $this->assertSame( $expected, $store->reloadMap() ); + $this->assertSame( $expected, $store->getMap() ); + } + public function testCacheRaceCondition() { $wanHashBag = new HashBagOStuff(); $store1 = $this->getNameTableSqlStore( $wanHashBag, 1, 1 );