Merge "Embed TinyRGB color profile when JPG EXIF Color Space = sRGB but no profile...
[lhc/web/wiklou.git] / tests / phpunit / includes / skins / SkinTemplateTest.php
1 <?php
2
3 /**
4 * @covers SkinTemplate
5 *
6 * @group Output
7 *
8 * @author Bene* < benestar.wikimedia@gmail.com >
9 */
10
11 class SkinTemplateTest extends MediaWikiTestCase {
12 /**
13 * @dataProvider makeListItemProvider
14 */
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
43 /**
44 * @return PHPUnit_Framework_MockObject_MockObject|OutputPage
45 */
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
87 /**
88 * @param PHPUnit_Framework_MockObject_MockObject|OutputPage $outputPageMock
89 * @param string[] $expectedModuleStyles
90 *
91 * @covers SkinTemplate::setupSkinUserCss
92 * @dataProvider provideSetupSkinUserCss
93 */
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 }