Implement support for 'hidden' feature in MediaWikiGadgetsDefinitionRepo

Follows-up 152484566, which added support for it in Gadgets 2.0, but
it's easy enough to make it work in existing definitions as well.

That way, people can stop using 'rights=hidden' hacks.

Bug: T33150
Change-Id: Idd6944a9ad38279e117c1a02a4b5fd0343455ba0
This commit is contained in:
Timo Tijhof 2016-11-16 17:58:37 -08:00 committed by Krinkle
parent 2bbbfe1b25
commit 27a0ca6568
2 changed files with 14 additions and 0 deletions

View file

@ -202,6 +202,9 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
case 'rights':
$info['requiredRights'] = $params;
break;
case 'hidden':
$info['hidden'] = true;
break;
case 'skins':
$info['requiredSkins'] = $params;
break;

View file

@ -130,6 +130,17 @@ class GadgetsTest extends MediaWikiTestCase {
$this->assertEquals( $mType, $this->getModule( $g )->getType(), "Module: $message" );
}
public function testIsHidden() {
$g = $this->create( '* foo[hidden]|bar.js' );
$this->assertTrue( $g->isHidden() );
$g = $this->create( '* foo[ResourceLoader|hidden]|bar.js' );
$this->assertTrue( $g->isHidden() );
$g = $this->create( '* foo[ResourceLoader]|bar.js' );
$this->assertFalse( $g->isHidden() );
}
public function testPreferences() {
$prefs = array();
$repo = TestingAccessWrapper::newFromObject( new MediaWikiGadgetsDefinitionRepo() );