mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-12-18 09:50:37 +00:00
0c61a5a468
As this repo is not used anywhere in production, there is no backward compatibility. Any scripts, styles, datas specified in existing definition pages will get ignored. Gadget::getJSON() no longer checks isPackaged() – that is now left for callers - only relevant one is in GadgetRLModule. That was done because validationWarnings() method needs the JSON page list even for non-package gadgets. Bug: T353174 Change-Id: Ic820bc4632981369c72f822fb8b9b7195930eaa6
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":{"pages":["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":{"pages":["Gadget:test.js"]}, "settings":{"default":true}}' );
|
|
$this->editPage( 'Gadget definition:X2',
|
|
'{"module":{"pages":["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() );
|
|
}
|
|
}
|