MediaWiki REL1_30
SkinTemplateTest.php
Go to the documentation of this file.
1<?php
2
15 public function testMakeListItem( $expected, $key, $item, $options, $message ) {
16 $template = $this->getMockForAbstractClass( 'BaseTemplate' );
17
18 $this->assertEquals(
19 $expected,
20 $template->makeListItem( $key, $item, $options ),
21 $message
22 );
23 }
24
25 public function makeListItemProvider() {
26 return [
27 [
28 '<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
29 '',
30 [
31 'class' => 'class',
32 'itemtitle' => 'itemtitle',
33 'href' => 'url',
34 'title' => 'title',
35 'text' => 'text'
36 ],
37 [],
38 'Test makeListItem with normal values'
39 ]
40 ];
41 }
42
46 private function getMockOutputPage( $isSyndicated, $html ) {
47 $mock = $this->getMockBuilder( OutputPage::class )
48 ->disableOriginalConstructor()
49 ->getMock();
50 $mock->expects( $this->once() )
51 ->method( 'isSyndicated' )
52 ->will( $this->returnValue( $isSyndicated ) );
53 $mock->expects( $this->once() )
54 ->method( 'getHTML' )
55 ->will( $this->returnValue( $html ) );
56 return $mock;
57 }
58
59 public function provideSetupSkinUserCss() {
60 $defaultStyles = [
61 'mediawiki.legacy.shared',
62 'mediawiki.legacy.commonPrint',
63 'mediawiki.sectionAnchor',
64 ];
65 $buttonStyle = 'mediawiki.ui.button';
66 $feedStyle = 'mediawiki.feedlink';
67 return [
68 [
69 $this->getMockOutputPage( false, '' ),
70 $defaultStyles
71 ],
72 [
73 $this->getMockOutputPage( true, '' ),
74 array_merge( $defaultStyles, [ $feedStyle ] )
75 ],
76 [
77 $this->getMockOutputPage( false, 'FOO mw-ui-button BAR' ),
78 array_merge( $defaultStyles, [ $buttonStyle ] )
79 ],
80 [
81 $this->getMockOutputPage( true, 'FOO mw-ui-button BAR' ),
82 array_merge( $defaultStyles, [ $feedStyle, $buttonStyle ] )
83 ],
84 ];
85 }
86
94 public function testSetupSkinUserCss( $outputPageMock, $expectedModuleStyles ) {
95 $outputPageMock->expects( $this->once() )
96 ->method( 'addModuleStyles' )
97 ->with( $expectedModuleStyles );
98
99 $skinTemplate = new SkinTemplate();
100 $skinTemplate->setupSkinUserCss( $outputPageMock );
101 }
102}
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:829
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:1971
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:1983