MediaWiki REL1_31
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->once() )
53 ->method( 'getHTML' )
54 ->will( $this->returnValue( $html ) );
55 return $mock;
56 }
57
58 public function provideSetupSkinUserCss() {
59 $defaultStyles = [
60 'mediawiki.legacy.shared',
61 'mediawiki.legacy.commonPrint',
62 'mediawiki.sectionAnchor',
63 ];
64 $buttonStyle = 'mediawiki.ui.button';
65 $feedStyle = 'mediawiki.feedlink';
66 return [
67 [
68 $this->getMockOutputPage( false, '' ),
69 $defaultStyles
70 ],
71 [
72 $this->getMockOutputPage( true, '' ),
73 array_merge( $defaultStyles, [ $feedStyle ] )
74 ],
75 [
76 $this->getMockOutputPage( false, 'FOO mw-ui-button BAR' ),
77 array_merge( $defaultStyles, [ $buttonStyle ] )
78 ],
79 [
80 $this->getMockOutputPage( true, 'FOO mw-ui-button BAR' ),
81 array_merge( $defaultStyles, [ $feedStyle, $buttonStyle ] )
82 ],
83 ];
84 }
85
93 public function testSetupSkinUserCss( $outputPageMock, $expectedModuleStyles ) {
94 $outputPageMock->expects( $this->once() )
95 ->method( 'addModuleStyles' )
96 ->with( $expectedModuleStyles );
97
98 $skinTemplate = new SkinTemplate();
99 $skinTemplate->setupSkinUserCss( $outputPageMock );
100 }
101}
testMakeListItem( $expected, $key, $item, $options, $message)
makeListItemProvider
testSetupSkinUserCss( $outputPageMock, $expectedModuleStyles)
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 probably a stub 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:831
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:2001
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:2013