mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-12-18 01:40:31 +00:00
Add tests for cache invalidations in MWGadgetDefinitionRepo
Change-Id: I24af0c2fa7524b5d6b5cd2cb151d3617c99a6ab0
This commit is contained in:
parent
6f9f46b510
commit
c665a90423
|
@ -31,4 +31,36 @@ EOT;
|
||||||
$this->assertEquals( 'keep-section1', $bar->toArray()['category'] );
|
$this->assertEquals( 'keep-section1', $bar->toArray()['category'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \MediaWiki\Extension\Gadgets\Hooks::onPageSaveComplete
|
||||||
|
* @covers \MediaWiki\Extension\Gadgets\Hooks::onPageDeleteComplete
|
||||||
|
* @covers \MediaWiki\Extension\Gadgets\GadgetRepo::handlePageUpdate
|
||||||
|
* @covers \MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo
|
||||||
|
*/
|
||||||
|
public function testCacheInvalidationOnSave() {
|
||||||
|
$services = $this->getServiceContainer();
|
||||||
|
$wanCache = WANObjectCache::newEmpty();
|
||||||
|
$wanCache->useInterimHoldOffCaching( false );
|
||||||
|
|
||||||
|
$repo = new MediaWikiGadgetsDefinitionRepo( $wanCache, $services->getRevisionLookup() );
|
||||||
|
$this->setService( 'GadgetsRepo', $repo );
|
||||||
|
|
||||||
|
$this->editPage( 'MediaWiki:Gadgets-definition', '* X1[ResourceLoader|default]|foo.js' );
|
||||||
|
$this->assertEquals( [ 'X1' ], $repo->getGadgetIds() );
|
||||||
|
$this->assertTrue( $repo->getGadget( 'X1' )->isOnByDefault() );
|
||||||
|
|
||||||
|
$this->editPage( 'MediaWiki:Gadgets-definition', "* X1[ResourceLoader|default]|foo.js\n" .
|
||||||
|
"* X2[ResourceLoader|default]|foo.css" );
|
||||||
|
$this->assertEquals( [ 'X1', 'X2' ], $repo->getGadgetIds() );
|
||||||
|
|
||||||
|
// Disable X1 by default
|
||||||
|
$this->editPage( 'MediaWiki:Gadgets-definition', "* X1[ResourceLoader]|foo.js\n" .
|
||||||
|
"* X2[ResourceLoader|default]|foo.css" );
|
||||||
|
$this->assertFalse( $repo->getGadget( 'X1' )->isOnByDefault() );
|
||||||
|
|
||||||
|
$this->deletePage( $services->getWikiPageFactory()->newFromTitle(
|
||||||
|
Title::newFromText( 'MediaWiki:Gadgets-definition' ) ) );
|
||||||
|
$this->assertEquals( [], $repo->getGadgetIds() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue