22 $this->user = $this->
getTestUser( [
'unittesters' ] )->getUser();
36 $g = $repo->newFromDefinition(
$line,
'misc' );
42 $module = TestingAccessWrapper::newFromObject(
54 $this->
assertFalse( $repo->newFromDefinition(
'',
'misc' ) );
55 $this->
assertFalse( $repo->newFromDefinition(
'<foo|bar>',
'misc' ) );
63 $g = $this->
create(
'* foo bar| foo.css|foo.js|foo.bar' );
66 $this->
assertEquals( [
'MediaWiki:Gadget-foo.js' ], $g->getScripts() );
67 $this->
assertEquals( [
'MediaWiki:Gadget-foo.css' ], $g->getStyles() );
68 $this->
assertEquals( [
'MediaWiki:Gadget-foo.js',
'MediaWiki:Gadget-foo.css' ],
69 $g->getScriptsAndStyles() );
70 $this->
assertEquals( [
'MediaWiki:Gadget-foo.js' ], $g->getLegacyScripts() );
81 $g = $this->
create(
'*foo [ResourceLoader]|foo.js|foo.css' );
83 $this->
assertTrue( $g->supportsResourceLoader() );
84 $this->
assertEquals( 0, count( $g->getLegacyScripts() ) );
92 $gUnset = $this->
create(
'*foo[ResourceLoader]|foo.js' );
93 $gAllowed = $this->
create(
'*bar[ResourceLoader|rights=test]|bar.js' );
94 $gNotAllowed = $this->
create(
'*baz[ResourceLoader|rights=nope]|baz.js' );
95 $this->
assertTrue( $gUnset->isAllowed( $this->user ) );
96 $this->
assertTrue( $gAllowed->isAllowed( $this->user ) );
97 $this->
assertFalse( $gNotAllowed->isAllowed( $this->user ) );
105 $gUnset = $this->
create(
'*foo[ResourceLoader]|foo.js' );
106 $gSkinSupported = $this->
create(
'*bar[ResourceLoader|skins=fallback]|bar.js' );
107 $gSkinNotSupported = $this->
create(
'*baz[ResourceLoader|skins=bar]|baz.js' );
109 $this->
assertTrue( $gUnset->isSkinSupported( $skin ) );
110 $this->
assertTrue( $gSkinSupported->isSkinSupported( $skin ) );
111 $this->
assertFalse( $gSkinNotSupported->isSkinSupported( $skin ) );
119 $g = $this->
create(
'* foo[ResourceLoader|dependencies=jquery.ui]|bar.js' );
120 $this->
assertEquals( [
'MediaWiki:Gadget-bar.js' ], $g->getScripts() );
121 $this->
assertTrue( $g->supportsResourceLoader() );
122 $this->
assertEquals( [
'jquery.ui' ], $g->getDependencies() );
129 '* foo[ResourceLoader]|bar.css|bar.js',
134 'Default (styles only)',
135 '* foo[ResourceLoader]|bar.css',
140 'Default (scripts only)',
141 '* foo[ResourceLoader]|bar.js',
146 'Default (styles only with dependencies)',
147 '* foo[ResourceLoader|dependencies=jquery.ui]|bar.css',
152 'Styles type (mixed)',
153 '* foo[ResourceLoader|type=styles]|bar.css|bar.js',
158 'Styles type (styles only)',
159 '* foo[ResourceLoader|type=styles]|bar.css',
164 'Styles type (scripts only)',
165 '* foo[ResourceLoader|type=styles]|bar.js',
170 'General type (mixed)',
171 '* foo[ResourceLoader|type=general]|bar.css|bar.js',
176 'General type (styles only)',
177 '* foo[ResourceLoader|type=general]|bar.css',
182 'General type (scripts only)',
183 '* foo[ResourceLoader|type=general]|bar.js',
196 public function testType( $message, $definition, $gType, $mType ) {
197 $g = $this->
create( $definition );
198 $this->
assertEquals( $gType, $g->getType(),
"Gadget: $message" );
207 $g = $this->
create(
'* foo[hidden]|bar.js' );
210 $g = $this->
create(
'* foo[ResourceLoader|hidden]|bar.js' );
213 $g = $this->
create(
'* foo[ResourceLoader]|bar.js' );
229 $gadgets = $repo->fetchStructuredList(
'* foo | foo.js
233* baz [rights=embezzle] |baz.js
235* quux [rights=test] | quux.js' );
240 'GetPrefences hook should return true' );
242 $options = $prefs[
'gadgets'][
'options'];
244 'Must not show empty sections' );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgGroupPermissions['sysop']['replacetext']
static getPreferences( $user, &$preferences)
GetPreferences hook handler.
static setSingleton( $repo=null)
Should only be used by unit tests.
Class representing a list of resources for one gadget, basically a wrapper around the Gadget class.
testDependencies()
MediaWikiGadgetsDefinitionRepo::newFromDefinition Gadget::getDependencies.
testPreferences()
Gadget GadgetHooks::getPreferences GadgetRepo MediaWikiGadgetsDefinitionRepo.
testType( $message, $definition, $gType, $mType)
provideGetType MediaWikiGadgetsDefinitionRepo::newFromDefinition Gadget::getType GadgetResourceLoader...
testInvalidLines()
MediaWikiGadgetsDefinitionRepo::newFromDefinition.
testRLtag()
MediaWikiGadgetsDefinitionRepo::newFromDefinition Gadget::supportsResourceLoader Gadget::getLegacyScr...
testSkinsTag()
MediaWikiGadgetsDefinitionRepo::newFromDefinition Gadget::isSkinSupported.
testSimpleCases()
MediaWikiGadgetsDefinitionRepo::newFromDefinition Gadget.
testisAllowed()
MediaWikiGadgetsDefinitionRepo::newFromDefinition Gadget::isAllowed.
testIsHidden()
MediaWikiGadgetsDefinitionRepo::newFromDefinition Gadget::isHidden.
static getModuleName( $id)
SkinTemplate class for the fallback skin.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options