mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-12-19 10:20:38 +00:00
ce486be160
* Separate out tests for MediaWikiGadgetsDefinitionRepo and Hooks::onGetPreferences. Removed hack in fetchStructuredList() for overriding page content for tests. * Add tests for ES6 gadgets. For this, ResourceLoaderModuleTest is converted back to an integration test. * Removed createGadgetDefinitionPage() test helper method. Now using MediaWikiIntegrationTestCase::editPage(). * Fixed GDNamespaceRepoTest failure when GDNamespaceRepo is the active repo, by clearing WAN process cache. Change-Id: I26b84576a91f6cb0ebae64c5fc1408666d767911
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Extension\Gadgets\GadgetDefinitionNamespaceRepo;
|
|
|
|
/**
|
|
* @group Gadgets
|
|
* @group Database
|
|
*/
|
|
class GadgetDefinitionNamespaceRepoTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Gadgets\GadgetDefinitionNamespaceRepo
|
|
*/
|
|
public function testGetGadget() {
|
|
$this->editPage( 'Gadget definition:Test',
|
|
'{"module":{"scripts":["test.js"]}, "settings":{"default":true}}' );
|
|
|
|
$services = $this->getServiceContainer();
|
|
$repo = new GadgetDefinitionNamespaceRepo( $services->getMainWANObjectCache(), $services->getRevisionLookup() );
|
|
$gadget = $repo->getGadget( 'Test' );
|
|
$this->assertTrue( $gadget->isOnByDefault() );
|
|
$this->assertArrayEquals( [ "Gadget:test.js" ], $gadget->getScripts() );
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Gadgets\GadgetDefinitionNamespaceRepo
|
|
*/
|
|
public function testGetGadgetIds() {
|
|
$this->editPage( 'Gadget definition:X1',
|
|
'{"module":{"scripts":["Gadget:test.js"]}, "settings":{"default":true}}' );
|
|
$this->editPage( 'Gadget definition:X2',
|
|
'{"module":{"scripts":["Gadget:test.js"]}, "settings":{"default":true}}' );
|
|
|
|
$services = $this->getServiceContainer();
|
|
$wanCache = $services->getMainWANObjectCache();
|
|
$repo = new GadgetDefinitionNamespaceRepo( $wanCache, $services->getRevisionLookup() );
|
|
$wanCache->clearProcessCache();
|
|
$this->assertArrayEquals( [ 'X1', 'X2' ], $repo->getGadgetIds() );
|
|
}
|
|
}
|