Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / ClearInterwikiCacheTest.php
blob7e07fd9c0a1e6357b5c72d6c7802ba1887885e37
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use ClearInterwikiCache;
6 use MediaWiki\Interwiki\InterwikiLookup;
8 /**
9 * @covers \ClearInterwikiCache
10 * @group Database
11 * @author Dreamy Jazz
13 class ClearInterwikiCacheTest extends MaintenanceBaseTestCase {
15 protected function getMaintenanceClass() {
16 return ClearInterwikiCache::class;
19 public function testExecute() {
20 // Insert some testing interwiki table rows
21 $this->getDb()->newInsertQueryBuilder()
22 ->insertInto( 'interwiki' )
23 ->rows( [
25 'iw_prefix' => 'en',
26 'iw_url' => 'test$1',
27 'iw_api' => 'testapi$1',
28 'iw_wikiid' => 'enwiki',
29 'iw_local' => 0,
30 'iw_trans' => 0,
33 'iw_prefix' => 'de',
34 'iw_url' => 'de.test$1',
35 'iw_api' => 'de.testapi$1',
36 'iw_wikiid' => 'dewiki',
37 'iw_local' => 0,
38 'iw_trans' => 0,
40 ] )
41 ->execute();
42 // Mock that the InterwikiLookup::invalidateCache method is called.
43 $this->setService( 'InterwikiLookup', function () {
44 $mockInterwikiLookup = $this->createMock( InterwikiLookup::class );
45 $mockInterwikiLookup->expects( $this->exactly( 2 ) )
46 ->method( 'invalidateCache' )
47 ->willReturnCallback( function ( $prefix ) {
48 $this->assertContains( $prefix, [ 'en', 'de' ] );
49 } );
50 return $mockInterwikiLookup;
51 } );
52 $this->maintenance->execute();