3 namespace MediaWiki\Tests\Maintenance
;
5 use ClearInterwikiCache
;
6 use MediaWiki\Interwiki\InterwikiLookup
;
9 * @covers \ClearInterwikiCache
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' )
27 'iw_api' => 'testapi$1',
28 'iw_wikiid' => 'enwiki',
34 'iw_url' => 'de.test$1',
35 'iw_api' => 'de.testapi$1',
36 'iw_wikiid' => 'dewiki',
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' ] );
50 return $mockInterwikiLookup;
52 $this->maintenance
->execute();