Merge "Output converted namespace name in nstab when nstab-* is not defined"
[lhc/web/wiklou.git] / tests / phpunit / includes / resourceloader / ResourceLoaderImageModuleTest.php
1 <?php
2
3 /**
4 * @group ResourceLoader
5 */
6 class ResourceLoaderImageModuleTest extends ResourceLoaderTestCase {
7
8 public static $commonImageData = array(
9 'add' => 'add.gif',
10 'remove' => array(
11 'file' => 'remove.svg',
12 'variants' => array( 'destructive' ),
13 ),
14 'next' => array(
15 'file' => array(
16 'ltr' => 'next.svg',
17 'rtl' => 'prev.svg'
18 ),
19 ),
20 'help' => array(
21 'file' => array(
22 'ltr' => 'help-ltr.svg',
23 'rtl' => 'help-rtl.svg',
24 'lang' => array(
25 'he' => 'help-ltr.svg',
26 )
27 ),
28 ),
29 'bold' => array(
30 'file' => array(
31 'default' => 'bold-a.svg',
32 'lang' => array(
33 'en' => 'bold-b.svg',
34 'ar,de' => 'bold-f.svg',
35 )
36 ),
37 )
38 );
39
40 public static $commonImageVariants = array(
41 'invert' => array(
42 'color' => '#FFFFFF',
43 'global' => true,
44 ),
45 'primary' => array(
46 'color' => '#598AD1',
47 ),
48 'constructive' => array(
49 'color' => '#00C697',
50 ),
51 'destructive' => array(
52 'color' => '#E81915',
53 ),
54 );
55
56 public static function providerGetModules() {
57 return array(
58 array(
59 array(
60 'class' => 'ResourceLoaderImageModule',
61 'prefix' => 'oo-ui-icon',
62 'variants' => self::$commonImageVariants,
63 'images' => self::$commonImageData,
64 ),
65 '.oo-ui-icon-add {
66 ...
67 }
68 .oo-ui-icon-add-invert {
69 ...
70 }
71 .oo-ui-icon-remove {
72 ...
73 }
74 .oo-ui-icon-remove-invert {
75 ...
76 }
77 .oo-ui-icon-remove-destructive {
78 ...
79 }
80 .oo-ui-icon-next {
81 ...
82 }
83 .oo-ui-icon-next-invert {
84 ...
85 }
86 .oo-ui-icon-help {
87 ...
88 }
89 .oo-ui-icon-help-invert {
90 ...
91 }
92 .oo-ui-icon-bold {
93 ...
94 }
95 .oo-ui-icon-bold-invert {
96 ...
97 }',
98 ),
99 array(
100 array(
101 'class' => 'ResourceLoaderImageModule',
102 'selectorWithoutVariant' => '.mw-ui-icon-{name}:after, .mw-ui-icon-{name}:before',
103 'selectorWithVariant' => '.mw-ui-icon-{name}-{variant}:after, .mw-ui-icon-{name}-{variant}:before',
104 'variants' => self::$commonImageVariants,
105 'images' => self::$commonImageData,
106 ),
107 '.mw-ui-icon-add:after, .mw-ui-icon-add:before {
108 ...
109 }
110 .mw-ui-icon-add-invert:after, .mw-ui-icon-add-invert:before {
111 ...
112 }
113 .mw-ui-icon-remove:after, .mw-ui-icon-remove:before {
114 ...
115 }
116 .mw-ui-icon-remove-invert:after, .mw-ui-icon-remove-invert:before {
117 ...
118 }
119 .mw-ui-icon-remove-destructive:after, .mw-ui-icon-remove-destructive:before {
120 ...
121 }
122 .mw-ui-icon-next:after, .mw-ui-icon-next:before {
123 ...
124 }
125 .mw-ui-icon-next-invert:after, .mw-ui-icon-next-invert:before {
126 ...
127 }
128 .mw-ui-icon-help:after, .mw-ui-icon-help:before {
129 ...
130 }
131 .mw-ui-icon-help-invert:after, .mw-ui-icon-help-invert:before {
132 ...
133 }
134 .mw-ui-icon-bold:after, .mw-ui-icon-bold:before {
135 ...
136 }
137 .mw-ui-icon-bold-invert:after, .mw-ui-icon-bold-invert:before {
138 ...
139 }',
140 ),
141 );
142 }
143
144 /**
145 * @dataProvider providerGetModules
146 * @covers ResourceLoaderImageModule::getStyles
147 */
148 public function testGetStyles( $module, $expected ) {
149 $module = new ResourceLoaderImageModuleTestable( $module, __DIR__ . '/../../data/resourceloader' );
150 $styles = $module->getStyles( $this->getResourceLoaderContext() );
151 $this->assertEquals( $expected, $styles['all'] );
152 }
153 }
154
155 class ResourceLoaderImageModuleTestable extends ResourceLoaderImageModule {
156 /**
157 * Replace with a stub to make test cases easier to write.
158 */
159 protected function getCssDeclarations( $primary, $fallback ) {
160 return array( '...' );
161 }
162 }