1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
<?php
/**
* @covers SkinTemplate
*
* @group Output
*
* @author Bene* < benestar.wikimedia@gmail.com >
*/
class SkinTemplateTest extends MediaWikiTestCase {
/**
* @dataProvider makeListItemProvider
*/
public function testMakeListItem( $expected, $key, $item, $options, $message ) {
$template = $this->getMockForAbstractClass( BaseTemplate::class );
$this->assertEquals(
$expected,
$template->makeListItem( $key, $item, $options ),
$message
);
}
public function makeListItemProvider() {
return [
[
'<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
'',
[
'class' => 'class',
'itemtitle' => 'itemtitle',
'href' => 'url',
'title' => 'title',
'text' => 'text'
],
[],
'Test makeListItem with normal values'
]
];
}
/**
* @return PHPUnit_Framework_MockObject_MockObject|OutputPage
*/
private function getMockOutputPage( $isSyndicated, $html ) {
$mock = $this->getMockBuilder( OutputPage::class )
->disableOriginalConstructor()
->getMock();
$mock->expects( $this->once() )
->method( 'isSyndicated' )
->will( $this->returnValue( $isSyndicated ) );
$mock->expects( $this->once() )
->method( 'getHTML' )
->will( $this->returnValue( $html ) );
return $mock;
}
public function provideSetupSkinUserCss() {
$defaultStyles = [
'mediawiki.legacy.shared',
'mediawiki.legacy.commonPrint',
'mediawiki.sectionAnchor',
];
$buttonStyle = 'mediawiki.ui.button';
$feedStyle = 'mediawiki.feedlink';
return [
[
$this->getMockOutputPage( false, '' ),
$defaultStyles
],
[
$this->getMockOutputPage( true, '' ),
array_merge( $defaultStyles, [ $feedStyle ] )
],
[
$this->getMockOutputPage( false, 'FOO mw-ui-button BAR' ),
array_merge( $defaultStyles, [ $buttonStyle ] )
],
[
$this->getMockOutputPage( true, 'FOO mw-ui-button BAR' ),
array_merge( $defaultStyles, [ $feedStyle, $buttonStyle ] )
],
];
}
/**
* @param PHPUnit_Framework_MockObject_MockObject|OutputPage $outputPageMock
* @param string[] $expectedModuleStyles
*
* @covers SkinTemplate::setupSkinUserCss
* @dataProvider provideSetupSkinUserCss
*/
public function testSetupSkinUserCss( $outputPageMock, $expectedModuleStyles ) {
$outputPageMock->expects( $this->once() )
->method( 'addModuleStyles' )
->with( $expectedModuleStyles );
$skinTemplate = new SkinTemplate();
$skinTemplate->setupSkinUserCss( $outputPageMock );
}
}
|