Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / HtmlTest.php
blob830a7be2fdf61e3629e06bb580ca7546865321cf
1 <?php
2 /** tests for includes/Html.php */
4 class HtmlTest extends MediaWikiTestCase {
6 protected function setUp() {
7 parent::setUp();
9 $langCode = 'en';
10 $langObj = Language::factory( $langCode );
12 // Hardcode namespaces during test runs,
13 // so that html output based on existing namespaces
14 // can be properly evaluated.
15 $langObj->setNamespaces( array(
16 -2 => 'Media',
17 -1 => 'Special',
18 0 => '',
19 1 => 'Talk',
20 2 => 'User',
21 3 => 'User_talk',
22 4 => 'MyWiki',
23 5 => 'MyWiki_Talk',
24 6 => 'File',
25 7 => 'File_talk',
26 8 => 'MediaWiki',
27 9 => 'MediaWiki_talk',
28 10 => 'Template',
29 11 => 'Template_talk',
30 14 => 'Category',
31 15 => 'Category_talk',
32 100 => 'Custom',
33 101 => 'Custom_talk',
34 ) );
36 $this->setMwGlobals( array(
37 'wgLanguageCode' => $langCode,
38 'wgContLang' => $langObj,
39 'wgLang' => $langObj,
40 'wgWellFormedXml' => false,
41 ) );
44 /**
45 * @covers Html::element
47 public function testElementBasics() {
48 $this->assertEquals(
49 '<img>',
50 Html::element( 'img', null, '' ),
51 'No close tag for short-tag elements'
54 $this->assertEquals(
55 '<element></element>',
56 Html::element( 'element', null, null ),
57 'Close tag for empty element (null, null)'
60 $this->assertEquals(
61 '<element></element>',
62 Html::element( 'element', array(), '' ),
63 'Close tag for empty element (array, string)'
66 $this->setMwGlobals( 'wgWellFormedXml', true );
68 $this->assertEquals(
69 '<img />',
70 Html::element( 'img', null, '' ),
71 'Self-closing tag for short-tag elements (wgWellFormedXml = true)'
75 public function dataXmlMimeType() {
76 return array(
77 // ( $mimetype, $isXmlMimeType )
78 # HTML is not an XML MimeType
79 array( 'text/html', false ),
80 # XML is an XML MimeType
81 array( 'text/xml', true ),
82 array( 'application/xml', true ),
83 # XHTML is an XML MimeType
84 array( 'application/xhtml+xml', true ),
85 # Make sure other +xml MimeTypes are supported
86 # SVG is another random MimeType even though we don't use it
87 array( 'image/svg+xml', true ),
88 # Complete random other MimeTypes are not XML
89 array( 'text/plain', false ),
93 /**
94 * @dataProvider dataXmlMimeType
95 * @covers Html::isXmlMimeType
97 public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
98 $this->assertEquals( $isXmlMimeType, Html::isXmlMimeType( $mimetype ) );
102 * @covers HTML::expandAttributes
104 public function testExpandAttributesSkipsNullAndFalse() {
106 # ## EMPTY ########
107 $this->assertEmpty(
108 Html::expandAttributes( array( 'foo' => null ) ),
109 'skip keys with null value'
111 $this->assertEmpty(
112 Html::expandAttributes( array( 'foo' => false ) ),
113 'skip keys with false value'
115 $this->assertEquals(
116 ' foo=""',
117 Html::expandAttributes( array( 'foo' => '' ) ),
118 'keep keys with an empty string'
123 * @covers HTML::expandAttributes
125 public function testExpandAttributesForBooleans() {
126 $this->assertEquals(
128 Html::expandAttributes( array( 'selected' => false ) ),
129 'Boolean attributes do not generates output when value is false'
131 $this->assertEquals(
133 Html::expandAttributes( array( 'selected' => null ) ),
134 'Boolean attributes do not generates output when value is null'
137 $this->assertEquals(
138 ' selected',
139 Html::expandAttributes( array( 'selected' => true ) ),
140 'Boolean attributes have no value when value is true'
142 $this->assertEquals(
143 ' selected',
144 Html::expandAttributes( array( 'selected' ) ),
145 'Boolean attributes have no value when value is true (passed as numerical array)'
148 $this->setMwGlobals( 'wgWellFormedXml', true );
150 $this->assertEquals(
151 ' selected=""',
152 Html::expandAttributes( array( 'selected' => true ) ),
153 'Boolean attributes have empty string value when value is true (wgWellFormedXml)'
158 * @covers HTML::expandAttributes
160 public function testExpandAttributesForNumbers() {
161 $this->assertEquals(
162 ' value=1',
163 Html::expandAttributes( array( 'value' => 1 ) ),
164 'Integer value is cast to a string'
166 $this->assertEquals(
167 ' value=1.1',
168 Html::expandAttributes( array( 'value' => 1.1 ) ),
169 'Float value is cast to a string'
174 * @covers HTML::expandAttributes
176 public function testExpandAttributesForObjects() {
177 $this->assertEquals(
178 ' value=stringValue',
179 Html::expandAttributes( array( 'value' => new HtmlTestValue() ) ),
180 'Object value is converted to a string'
185 * Test for Html::expandAttributes()
186 * Please note it output a string prefixed with a space!
187 * @covers Html::expandAttributes
189 public function testExpandAttributesVariousExpansions() {
190 # ## NOT EMPTY ####
191 $this->assertEquals(
192 ' empty_string=""',
193 Html::expandAttributes( array( 'empty_string' => '' ) ),
194 'Empty string is always quoted'
196 $this->assertEquals(
197 ' key=value',
198 Html::expandAttributes( array( 'key' => 'value' ) ),
199 'Simple string value needs no quotes'
201 $this->assertEquals(
202 ' one=1',
203 Html::expandAttributes( array( 'one' => 1 ) ),
204 'Number 1 value needs no quotes'
206 $this->assertEquals(
207 ' zero=0',
208 Html::expandAttributes( array( 'zero' => 0 ) ),
209 'Number 0 value needs no quotes'
212 $this->setMwGlobals( 'wgWellFormedXml', true );
214 $this->assertEquals(
215 ' empty_string=""',
216 Html::expandAttributes( array( 'empty_string' => '' ) ),
217 'Attribute values are always quoted (wgWellFormedXml): Empty string'
219 $this->assertEquals(
220 ' key="value"',
221 Html::expandAttributes( array( 'key' => 'value' ) ),
222 'Attribute values are always quoted (wgWellFormedXml): Simple string'
224 $this->assertEquals(
225 ' one="1"',
226 Html::expandAttributes( array( 'one' => 1 ) ),
227 'Attribute values are always quoted (wgWellFormedXml): Number 1'
229 $this->assertEquals(
230 ' zero="0"',
231 Html::expandAttributes( array( 'zero' => 0 ) ),
232 'Attribute values are always quoted (wgWellFormedXml): Number 0'
237 * Html::expandAttributes has special features for HTML
238 * attributes that use space separated lists and also
239 * allows arrays to be used as values.
240 * @covers Html::expandAttributes
242 public function testExpandAttributesListValueAttributes() {
243 # ## STRING VALUES
244 $this->assertEquals(
245 ' class="redundant spaces here"',
246 Html::expandAttributes( array( 'class' => ' redundant spaces here ' ) ),
247 'Normalization should strip redundant spaces'
249 $this->assertEquals(
250 ' class="foo bar"',
251 Html::expandAttributes( array( 'class' => 'foo bar foo bar bar' ) ),
252 'Normalization should remove duplicates in string-lists'
254 # ## "EMPTY" ARRAY VALUES
255 $this->assertEquals(
256 ' class=""',
257 Html::expandAttributes( array( 'class' => array() ) ),
258 'Value with an empty array'
260 $this->assertEquals(
261 ' class=""',
262 Html::expandAttributes( array( 'class' => array( null, '', ' ', ' ' ) ) ),
263 'Array with null, empty string and spaces'
265 # ## NON-EMPTY ARRAY VALUES
266 $this->assertEquals(
267 ' class="foo bar"',
268 Html::expandAttributes( array( 'class' => array(
269 'foo',
270 'bar',
271 'foo',
272 'bar',
273 'bar',
274 ) ) ),
275 'Normalization should remove duplicates in the array'
277 $this->assertEquals(
278 ' class="foo bar"',
279 Html::expandAttributes( array( 'class' => array(
280 'foo bar',
281 'bar foo',
282 'foo',
283 'bar bar',
284 ) ) ),
285 'Normalization should remove duplicates in string-lists in the array'
290 * Test feature added by r96188, let pass attributes values as
291 * a PHP array. Restricted to class,rel, accesskey.
292 * @covers Html::expandAttributes
294 public function testExpandAttributesSpaceSeparatedAttributesWithBoolean() {
295 $this->assertEquals(
296 ' class="booltrue one"',
297 Html::expandAttributes( array( 'class' => array(
298 'booltrue' => true,
299 'one' => 1,
301 # Method use isset() internally, make sure we do discard
302 # attributes values which have been assigned well known values
303 'emptystring' => '',
304 'boolfalse' => false,
305 'zero' => 0,
306 'null' => null,
307 ) ) )
312 * How do we handle duplicate keys in HTML attributes expansion?
313 * We could pass a "class" the values: 'GREEN' and array( 'GREEN' => false )
314 * The later will take precedence.
316 * Feature added by r96188
317 * @covers Html::expandAttributes
319 public function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
320 $this->assertEquals(
321 ' class=""',
322 Html::expandAttributes( array( 'class' => array(
323 'GREEN',
324 'GREEN' => false,
325 'GREEN',
326 ) ) )
331 * @covers Html::expandAttributes
332 * @expectedException MWException
334 public function testExpandAttributes_ArrayOnNonListValueAttribute_ThrowsException() {
335 // Real-life test case found in the Popups extension (see Gerrit cf0fd64),
336 // when used with an outdated BetaFeatures extension (see Gerrit deda1e7)
337 Html::expandAttributes( array(
338 'src' => array(
339 'ltr' => 'ltr.svg',
340 'rtl' => 'rtl.svg'
342 ) );
346 * @covers Html::namespaceSelector
348 public function testNamespaceSelector() {
349 $this->assertEquals(
350 '<select id=namespace name=namespace>' . "\n" .
351 '<option value=0>(Main)</option>' . "\n" .
352 '<option value=1>Talk</option>' . "\n" .
353 '<option value=2>User</option>' . "\n" .
354 '<option value=3>User talk</option>' . "\n" .
355 '<option value=4>MyWiki</option>' . "\n" .
356 '<option value=5>MyWiki Talk</option>' . "\n" .
357 '<option value=6>File</option>' . "\n" .
358 '<option value=7>File talk</option>' . "\n" .
359 '<option value=8>MediaWiki</option>' . "\n" .
360 '<option value=9>MediaWiki talk</option>' . "\n" .
361 '<option value=10>Template</option>' . "\n" .
362 '<option value=11>Template talk</option>' . "\n" .
363 '<option value=14>Category</option>' . "\n" .
364 '<option value=15>Category talk</option>' . "\n" .
365 '<option value=100>Custom</option>' . "\n" .
366 '<option value=101>Custom talk</option>' . "\n" .
367 '</select>',
368 Html::namespaceSelector(),
369 'Basic namespace selector without custom options'
372 $this->assertEquals(
373 '<label for=mw-test-namespace>Select a namespace:</label>&#160;' .
374 '<select id=mw-test-namespace name=wpNamespace>' . "\n" .
375 '<option value=all>all</option>' . "\n" .
376 '<option value=0>(Main)</option>' . "\n" .
377 '<option value=1>Talk</option>' . "\n" .
378 '<option value=2 selected>User</option>' . "\n" .
379 '<option value=3>User talk</option>' . "\n" .
380 '<option value=4>MyWiki</option>' . "\n" .
381 '<option value=5>MyWiki Talk</option>' . "\n" .
382 '<option value=6>File</option>' . "\n" .
383 '<option value=7>File talk</option>' . "\n" .
384 '<option value=8>MediaWiki</option>' . "\n" .
385 '<option value=9>MediaWiki talk</option>' . "\n" .
386 '<option value=10>Template</option>' . "\n" .
387 '<option value=11>Template talk</option>' . "\n" .
388 '<option value=14>Category</option>' . "\n" .
389 '<option value=15>Category talk</option>' . "\n" .
390 '<option value=100>Custom</option>' . "\n" .
391 '<option value=101>Custom talk</option>' . "\n" .
392 '</select>',
393 Html::namespaceSelector(
394 array( 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ),
395 array( 'name' => 'wpNamespace', 'id' => 'mw-test-namespace' )
397 'Basic namespace selector with custom values'
400 $this->assertEquals(
401 '<label for=namespace>Select a namespace:</label>&#160;' .
402 '<select id=namespace name=namespace>' . "\n" .
403 '<option value=0>(Main)</option>' . "\n" .
404 '<option value=1>Talk</option>' . "\n" .
405 '<option value=2>User</option>' . "\n" .
406 '<option value=3>User talk</option>' . "\n" .
407 '<option value=4>MyWiki</option>' . "\n" .
408 '<option value=5>MyWiki Talk</option>' . "\n" .
409 '<option value=6>File</option>' . "\n" .
410 '<option value=7>File talk</option>' . "\n" .
411 '<option value=8>MediaWiki</option>' . "\n" .
412 '<option value=9>MediaWiki talk</option>' . "\n" .
413 '<option value=10>Template</option>' . "\n" .
414 '<option value=11>Template talk</option>' . "\n" .
415 '<option value=14>Category</option>' . "\n" .
416 '<option value=15>Category talk</option>' . "\n" .
417 '<option value=100>Custom</option>' . "\n" .
418 '<option value=101>Custom talk</option>' . "\n" .
419 '</select>',
420 Html::namespaceSelector(
421 array( 'label' => 'Select a namespace:' )
423 'Basic namespace selector with a custom label but no id attribtue for the <select>'
427 public function testCanFilterOutNamespaces() {
428 $this->assertEquals(
429 '<select id=namespace name=namespace>' . "\n" .
430 '<option value=2>User</option>' . "\n" .
431 '<option value=4>MyWiki</option>' . "\n" .
432 '<option value=5>MyWiki Talk</option>' . "\n" .
433 '<option value=6>File</option>' . "\n" .
434 '<option value=7>File talk</option>' . "\n" .
435 '<option value=8>MediaWiki</option>' . "\n" .
436 '<option value=9>MediaWiki talk</option>' . "\n" .
437 '<option value=10>Template</option>' . "\n" .
438 '<option value=11>Template talk</option>' . "\n" .
439 '<option value=14>Category</option>' . "\n" .
440 '<option value=15>Category talk</option>' . "\n" .
441 '</select>',
442 Html::namespaceSelector(
443 array( 'exclude' => array( 0, 1, 3, 100, 101 ) )
445 'Namespace selector namespace filtering.'
449 public function testCanDisableANamespaces() {
450 $this->assertEquals(
451 '<select id=namespace name=namespace>' . "\n" .
452 '<option disabled value=0>(Main)</option>' . "\n" .
453 '<option disabled value=1>Talk</option>' . "\n" .
454 '<option disabled value=2>User</option>' . "\n" .
455 '<option disabled value=3>User talk</option>' . "\n" .
456 '<option disabled value=4>MyWiki</option>' . "\n" .
457 '<option value=5>MyWiki Talk</option>' . "\n" .
458 '<option value=6>File</option>' . "\n" .
459 '<option value=7>File talk</option>' . "\n" .
460 '<option value=8>MediaWiki</option>' . "\n" .
461 '<option value=9>MediaWiki talk</option>' . "\n" .
462 '<option value=10>Template</option>' . "\n" .
463 '<option value=11>Template talk</option>' . "\n" .
464 '<option value=14>Category</option>' . "\n" .
465 '<option value=15>Category talk</option>' . "\n" .
466 '<option value=100>Custom</option>' . "\n" .
467 '<option value=101>Custom talk</option>' . "\n" .
468 '</select>',
469 Html::namespaceSelector( array(
470 'disable' => array( 0, 1, 2, 3, 4 )
471 ) ),
472 'Namespace selector namespace disabling'
477 * @dataProvider provideHtml5InputTypes
478 * @covers Html::element
480 public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
481 $this->assertEquals(
482 '<input type=' . $HTML5InputType . '>',
483 Html::element( 'input', array( 'type' => $HTML5InputType ) ),
484 'In HTML5, HTML::element() should accept type="' . $HTML5InputType . '"'
489 * List of input element types values introduced by HTML5
490 * Full list at http://www.w3.org/TR/html-markup/input.html
492 public static function provideHtml5InputTypes() {
493 $types = array(
494 'datetime',
495 'datetime-local',
496 'date',
497 'month',
498 'time',
499 'week',
500 'number',
501 'range',
502 'email',
503 'url',
504 'search',
505 'tel',
506 'color',
508 $cases = array();
509 foreach ( $types as $type ) {
510 $cases[] = array( $type );
513 return $cases;
517 * Test out Html::element drops or enforces default value
518 * @covers Html::dropDefaults
519 * @dataProvider provideElementsWithAttributesHavingDefaultValues
521 public function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
522 $this->assertEquals( $expected, Html::element( $element, $attribs ), $message );
525 public static function provideElementsWithAttributesHavingDefaultValues() {
526 # Use cases in a concise format:
527 # <expected>, <element name>, <array of attributes> [, <message>]
528 # Will be mapped to Html::element()
529 $cases = array();
531 # ## Generic cases, match $attribDefault static array
532 $cases[] = array( '<area>',
533 'area', array( 'shape' => 'rect' )
536 $cases[] = array( '<button type=submit></button>',
537 'button', array( 'formaction' => 'GET' )
539 $cases[] = array( '<button type=submit></button>',
540 'button', array( 'formenctype' => 'application/x-www-form-urlencoded' )
543 $cases[] = array( '<canvas></canvas>',
544 'canvas', array( 'height' => '150' )
546 $cases[] = array( '<canvas></canvas>',
547 'canvas', array( 'width' => '300' )
549 # Also check with numeric values
550 $cases[] = array( '<canvas></canvas>',
551 'canvas', array( 'height' => 150 )
553 $cases[] = array( '<canvas></canvas>',
554 'canvas', array( 'width' => 300 )
557 $cases[] = array( '<command>',
558 'command', array( 'type' => 'command' )
561 $cases[] = array( '<form></form>',
562 'form', array( 'action' => 'GET' )
564 $cases[] = array( '<form></form>',
565 'form', array( 'autocomplete' => 'on' )
567 $cases[] = array( '<form></form>',
568 'form', array( 'enctype' => 'application/x-www-form-urlencoded' )
571 $cases[] = array( '<input>',
572 'input', array( 'formaction' => 'GET' )
574 $cases[] = array( '<input>',
575 'input', array( 'type' => 'text' )
578 $cases[] = array( '<keygen>',
579 'keygen', array( 'keytype' => 'rsa' )
582 $cases[] = array( '<link>',
583 'link', array( 'media' => 'all' )
586 $cases[] = array( '<menu></menu>',
587 'menu', array( 'type' => 'list' )
590 $cases[] = array( '<script></script>',
591 'script', array( 'type' => 'text/javascript' )
594 $cases[] = array( '<style></style>',
595 'style', array( 'media' => 'all' )
597 $cases[] = array( '<style></style>',
598 'style', array( 'type' => 'text/css' )
601 $cases[] = array( '<textarea></textarea>',
602 'textarea', array( 'wrap' => 'soft' )
605 # ## SPECIFIC CASES
607 # <link type="text/css">
608 $cases[] = array( '<link>',
609 'link', array( 'type' => 'text/css' )
612 # <input> specific handling
613 $cases[] = array( '<input type=checkbox>',
614 'input', array( 'type' => 'checkbox', 'value' => 'on' ),
615 'Default value "on" is stripped of checkboxes',
617 $cases[] = array( '<input type=radio>',
618 'input', array( 'type' => 'radio', 'value' => 'on' ),
619 'Default value "on" is stripped of radio buttons',
621 $cases[] = array( '<input type=submit value=Submit>',
622 'input', array( 'type' => 'submit', 'value' => 'Submit' ),
623 'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
625 $cases[] = array( '<input type=color>',
626 'input', array( 'type' => 'color', 'value' => '' ),
628 $cases[] = array( '<input type=range>',
629 'input', array( 'type' => 'range', 'value' => '' ),
632 # <button> specific handling
633 # see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
634 $cases[] = array( '<button type=submit></button>',
635 'button', array( 'type' => 'submit' ),
636 'According to standard the default type is "submit". '
637 . 'Depending on compatibility mode IE might use "button", instead.',
640 # <select> specific handling
641 $cases[] = array( '<select multiple></select>',
642 'select', array( 'size' => '4', 'multiple' => true ),
644 # .. with numeric value
645 $cases[] = array( '<select multiple></select>',
646 'select', array( 'size' => 4, 'multiple' => true ),
648 $cases[] = array( '<select></select>',
649 'select', array( 'size' => '1', 'multiple' => false ),
651 # .. with numeric value
652 $cases[] = array( '<select></select>',
653 'select', array( 'size' => 1, 'multiple' => false ),
656 # Passing an array as value
657 $cases[] = array( '<a class="css-class-one css-class-two"></a>',
658 'a', array( 'class' => array( 'css-class-one', 'css-class-two' ) ),
659 "dropDefaults accepts values given as an array"
662 # FIXME: doDropDefault should remove defaults given in an array
663 # Expected should be '<a></a>'
664 $cases[] = array( '<a class=""></a>',
665 'a', array( 'class' => array( '', '' ) ),
666 "dropDefaults accepts values given as an array"
669 # Craft the Html elements
670 $ret = array();
671 foreach ( $cases as $case ) {
672 $ret[] = array(
673 $case[0],
674 $case[1], $case[2],
675 isset( $case[3] ) ? $case[3] : ''
679 return $ret;
683 * @covers Html::expandAttributes
685 public function testFormValidationBlacklist() {
686 $this->assertEmpty(
687 Html::expandAttributes( array(
688 'min' => 1,
689 'max' => 100,
690 'pattern' => 'abc',
691 'required' => true,
692 'step' => 2
693 ) ),
694 'Blacklist form validation attributes.'
696 $this->assertEquals(
697 ' step=any',
698 Html::expandAttributes(
699 array(
700 'min' => 1,
701 'max' => 100,
702 'pattern' => 'abc',
703 'required' => true,
704 'step' => 'any'
706 'Allow special case "step=any".'
711 public function testWrapperInput() {
712 $this->assertEquals(
713 '<input type=radio value=testval name=testname>',
714 Html::input( 'testname', 'testval', 'radio' ),
715 'Input wrapper with type and value.'
717 $this->assertEquals(
718 '<input name=testname>',
719 Html::input( 'testname' ),
720 'Input wrapper with all default values.'
724 public function testWrapperCheck() {
725 $this->assertEquals(
726 '<input type=checkbox value=1 name=testname>',
727 Html::check( 'testname' ),
728 'Checkbox wrapper unchecked.'
730 $this->assertEquals(
731 '<input checked type=checkbox value=1 name=testname>',
732 Html::check( 'testname', true ),
733 'Checkbox wrapper checked.'
735 $this->assertEquals(
736 '<input type=checkbox value=testval name=testname>',
737 Html::check( 'testname', false, array( 'value' => 'testval' ) ),
738 'Checkbox wrapper with a value override.'
742 public function testWrapperRadio() {
743 $this->assertEquals(
744 '<input type=radio value=1 name=testname>',
745 Html::radio( 'testname' ),
746 'Radio wrapper unchecked.'
748 $this->assertEquals(
749 '<input checked type=radio value=1 name=testname>',
750 Html::radio( 'testname', true ),
751 'Radio wrapper checked.'
753 $this->assertEquals(
754 '<input type=radio value=testval name=testname>',
755 Html::radio( 'testname', false, array( 'value' => 'testval' ) ),
756 'Radio wrapper with a value override.'
760 public function testWrapperLabel() {
761 $this->assertEquals(
762 '<label for=testid>testlabel</label>',
763 Html::label( 'testlabel', 'testid' ),
764 'Label wrapper'
768 public static function provideSrcSetImages() {
769 return array(
770 array( array(), '', 'when there are no images, return empty string' ),
771 array(
772 array( '1x' => '1x.png', '1.5x' => '1_5x.png', '2x' => '2x.png' ),
773 '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
774 'pixel depth keys may include a trailing "x"'
776 array(
777 array( '1' => '1x.png', '1.5' => '1_5x.png', '2' => '2x.png' ),
778 '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
779 'pixel depth keys may omit a trailing "x"'
785 * @dataProvider provideSrcSetImages
786 * @covers Html::srcSet
788 public function testSrcSet( $images, $expected, $message ) {
789 $this->assertEquals( Html::srcSet( $images ), $expected, $message );
793 class HtmlTestValue {
794 function __toString() {
795 return 'stringValue';