mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-28 01:00:02 +00:00
a629d7f71d
MultiGadgetRepo is a wrapper around two or more GadgetRepos so that they can be used at the same, facilitating migration from one repo to another. If a gadget appears in both repos, the definition in the first repo takes precedence, and a warning is shown on Special:Gadgets. This can be enabled to wrap GadgetDefinitionNamespaceRepo and MediaWikiGadgetsDefinitionRepo by setting $wgGadgetsRepo to 'json+definition'. In this configuration, once a new JSON definition exists for the same name, it is used instead of the old one, and the old one can then safely be removed at a later time in the safe knowledge that it is no longer used. Adapted from If3cc5e22e9812d0fd1a9e8e269ea74a7f667dadd Bug: T140323 Co-authored-by: Kunal Mehta <legoktm@debian.org> Change-Id: Ibad53629e63ec8713d7a3b84a19838b94600588e
32 lines
1 KiB
PHP
32 lines
1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Extension\Gadgets\Gadget;
|
|
use MediaWiki\Extension\Gadgets\MultiGadgetRepo;
|
|
use MediaWiki\Extension\Gadgets\StaticGadgetRepo;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Gadgets\MultiGadgetRepo
|
|
* @group Gadgets
|
|
* @group Database
|
|
*/
|
|
class MultiGadgetRepoTest extends MediaWikiIntegrationTestCase {
|
|
public function testMultiGadgetRepo() {
|
|
$repo = new MultiGadgetRepo( [
|
|
new StaticGadgetRepo( [
|
|
'g1' => new Gadget( [ 'name' => 'g1', 'onByDefault' => true ] ),
|
|
'g2' => new Gadget( [ 'name' => 'g2', 'onByDefault' => true ] ),
|
|
] ),
|
|
new StaticGadgetRepo( [
|
|
'g1' => new Gadget( [ 'name' => 'g1', 'onByDefault' => false ] ),
|
|
'g3' => new Gadget( [ 'name' => 'g3', 'onByDefault' => false ] ),
|
|
] )
|
|
] );
|
|
|
|
$this->assertTrue( $repo->getGadget( 'g1' )->isOnByDefault() );
|
|
$this->assertTrue( $repo->getGadget( 'g2' )->isOnByDefault() );
|
|
$this->assertFalse( $repo->getGadget( 'g3' )->isOnByDefault() );
|
|
|
|
$this->assertCount( 1, $repo->validationWarnings( $repo->getGadget( 'g1' ) ) );
|
|
}
|
|
}
|