MediaWiki REL1_33
SkinTemplateTest.php
Go to the documentation of this file.
1<?php
2
14 public function testMakeListItem( $expected, $key, $item, $options, $message ) {
15 $template = $this->getMockForAbstractClass( BaseTemplate::class );
16
17 $this->assertEquals(
18 $expected,
19 $template->makeListItem( $key, $item, $options ),
20 $message
21 );
22 }
23
24 public function makeListItemProvider() {
25 return [
26 [
27 '<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
28 '',
29 [
30 'class' => 'class',
31 'itemtitle' => 'itemtitle',
32 'href' => 'url',
33 'title' => 'title',
34 'text' => 'text'
35 ],
36 [],
37 'Test makeListItem with normal values'
38 ]
39 ];
40 }
41
45 private function getMockOutputPage( $isSyndicated, $html ) {
46 $mock = $this->getMockBuilder( OutputPage::class )
47 ->disableOriginalConstructor()
48 ->getMock();
49 $mock->expects( $this->once() )
50 ->method( 'isSyndicated' )
51 ->will( $this->returnValue( $isSyndicated ) );
52 $mock->expects( $this->any() )
53 ->method( 'getHTML' )
54 ->will( $this->returnValue( $html ) );
55 return $mock;
56 }
57
58 public function provideGetDefaultModules() {
59 $defaultStyles = [
60 'mediawiki.legacy.shared',
61 'mediawiki.legacy.commonPrint',
62 ];
63 $buttonStyle = 'mediawiki.ui.button';
64 $feedStyle = 'mediawiki.feedlink';
65 return [
66 [
67 false,
68 '',
69 $defaultStyles
70 ],
71 [
72 true,
73 '',
74 array_merge( $defaultStyles, [ $feedStyle ] )
75 ],
76 [
77 false,
78 'FOO mw-ui-button BAR',
79 array_merge( $defaultStyles, [ $buttonStyle ] )
80 ],
81 [
82 true,
83 'FOO mw-ui-button BAR',
84 array_merge( $defaultStyles, [ $buttonStyle, $feedStyle ] )
85 ],
86 ];
87 }
88
93 public function testgetDefaultModules( $isSyndicated, $html, $expectedModuleStyles ) {
94 $skin = new SkinTemplate();
95
96 $context = new DerivativeContext( $skin->getContext() );
97 $context->setOutput( $this->getMockOutputPage( $isSyndicated, $html ) );
98 $skin->setContext( $context );
99
100 $modules = $skin->getDefaultModules();
101
102 $actualStylesModule = call_user_func_array( 'array_merge', $modules['styles'] );
103 $this->assertArraySubset(
104 $expectedModuleStyles,
105 $actualStylesModule,
106 'style modules'
107 );
108 }
109}
An IContextSource implementation which will inherit context from another source but allow individual ...
testgetDefaultModules( $isSyndicated, $html, $expectedModuleStyles)
Skin::getDefaultModules provideGetDefaultModules.
testMakeListItem( $expected, $key, $item, $options, $message)
makeListItemProvider
getMockOutputPage( $isSyndicated, $html)
Base class for template-based skins.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
Definition hooks.txt:822
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
Definition hooks.txt:1999
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2848
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:2011
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition hooks.txt:2009
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37