3 class HtmlTest
extends MediaWikiTestCase
{
4 private $restoreWarnings;
6 protected function setUp() {
10 'wgUseMediaWikiUIEverywhere' => false,
13 $contLangObj = Language
::factory( 'en' );
15 // Hardcode namespaces during test runs,
16 // so that html output based on existing namespaces
17 // can be properly evaluated.
18 $contLangObj->setNamespaces( [
30 9 => 'MediaWiki_talk',
32 11 => 'Template_talk',
34 15 => 'Category_talk',
38 $this->setContentLang( $contLangObj );
40 $userLangObj = Language
::factory( 'es' );
41 $userLangObj->setNamespaces( [
47 3 => "Usuario discusión",
49 5 => "Wiki discusión",
51 7 => "Archivo discusión",
53 9 => "MediaWiki discusión",
55 11 => "Plantilla discusión",
57 13 => "Ayuda discusión",
59 15 => "Categoría discusión",
60 100 => "Personalizado",
61 101 => "Personalizado discusión",
63 $this->setUserLang( $userLangObj );
65 $this->restoreWarnings
= false;
68 protected function tearDown() {
69 Language
::factory( 'en' )->resetNamespaces();
71 if ( $this->restoreWarnings
) {
72 $this->restoreWarnings
= false;
73 Wikimedia\restoreWarnings
();
80 * @expectedException PHPUnit_Framework_Error_Notice
81 * @expectedExceptionMessage given element name with space
82 * @covers Html::openElement
84 public function testOpenElement() {
85 Html
::openElement( 'span id="x"' );
89 * @covers Html::element
90 * @covers Html::rawElement
91 * @covers Html::openElement
92 * @covers Html::closeElement
94 public function testElementBasics() {
97 Html
::element( 'img', null, '' ),
98 'Self-closing tag for short-tag elements'
102 '<element></element>',
103 Html
::element( 'element', null, null ),
104 'Close tag for empty element (null, null)'
108 '<element></element>',
109 Html
::element( 'element', [], '' ),
110 'Close tag for empty element (array, string)'
114 public function dataXmlMimeType() {
116 // ( $mimetype, $isXmlMimeType )
117 # HTML is not an XML MimeType
118 [ 'text/html', false ],
119 # XML is an XML MimeType
120 [ 'text/xml', true ],
121 [ 'application/xml', true ],
122 # XHTML is an XML MimeType
123 [ 'application/xhtml+xml', true ],
124 # Make sure other +xml MimeTypes are supported
125 # SVG is another random MimeType even though we don't use it
126 [ 'image/svg+xml', true ],
127 # Complete random other MimeTypes are not XML
128 [ 'text/plain', false ],
133 * @dataProvider dataXmlMimeType
134 * @covers Html::isXmlMimeType
136 public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
137 $this->assertEquals( $isXmlMimeType, Html
::isXmlMimeType( $mimetype ) );
141 * @covers Html::expandAttributes
143 public function testExpandAttributesSkipsNullAndFalse() {
146 Html
::expandAttributes( [ 'foo' => null ] ),
147 'skip keys with null value'
150 Html
::expandAttributes( [ 'foo' => false ] ),
151 'skip keys with false value'
155 Html
::expandAttributes( [ 'foo' => '' ] ),
156 'keep keys with an empty string'
161 * @covers Html::expandAttributes
163 public function testExpandAttributesForBooleans() {
166 Html
::expandAttributes( [ 'selected' => false ] ),
167 'Boolean attributes do not generates output when value is false'
171 Html
::expandAttributes( [ 'selected' => null ] ),
172 'Boolean attributes do not generates output when value is null'
177 Html
::expandAttributes( [ 'selected' => true ] ),
178 'Boolean attributes have no value when value is true'
182 Html
::expandAttributes( [ 'selected' ] ),
183 'Boolean attributes have no value when value is true (passed as numerical array)'
188 * @covers Html::expandAttributes
190 public function testExpandAttributesForNumbers() {
193 Html
::expandAttributes( [ 'value' => 1 ] ),
194 'Integer value is cast to a string'
198 Html
::expandAttributes( [ 'value' => 1.1 ] ),
199 'Float value is cast to a string'
204 * @covers Html::expandAttributes
206 public function testExpandAttributesForObjects() {
208 ' value="stringValue"',
209 Html
::expandAttributes( [ 'value' => new HtmlTestValue() ] ),
210 'Object value is converted to a string'
215 * Test for Html::expandAttributes()
216 * Please note it output a string prefixed with a space!
217 * @covers Html::expandAttributes
219 public function testExpandAttributesVariousExpansions() {
223 Html
::expandAttributes( [ 'empty_string' => '' ] ),
224 'Empty string is always quoted'
228 Html
::expandAttributes( [ 'key' => 'value' ] ),
229 'Simple string value needs no quotes'
233 Html
::expandAttributes( [ 'one' => 1 ] ),
234 'Number 1 value needs no quotes'
238 Html
::expandAttributes( [ 'zero' => 0 ] ),
239 'Number 0 value needs no quotes'
244 * Html::expandAttributes has special features for HTML
245 * attributes that use space separated lists and also
246 * allows arrays to be used as values.
247 * @covers Html::expandAttributes
249 public function testExpandAttributesListValueAttributes() {
252 ' class="redundant spaces here"',
253 Html
::expandAttributes( [ 'class' => ' redundant spaces here ' ] ),
254 'Normalization should strip redundant spaces'
258 Html
::expandAttributes( [ 'class' => 'foo bar foo bar bar' ] ),
259 'Normalization should remove duplicates in string-lists'
261 # ## "EMPTY" ARRAY VALUES
264 Html
::expandAttributes( [ 'class' => [] ] ),
265 'Value with an empty array'
269 Html
::expandAttributes( [ 'class' => [ null, '', ' ', ' ' ] ] ),
270 'Array with null, empty string and spaces'
272 # ## NON-EMPTY ARRAY VALUES
275 Html
::expandAttributes( [ 'class' => [
282 'Normalization should remove duplicates in the array'
286 Html
::expandAttributes( [ 'class' => [
292 'Normalization should remove duplicates in string-lists in the array'
297 * Test feature added by r96188, let pass attributes values as
298 * a PHP array. Restricted to class,rel, accesskey.
299 * @covers Html::expandAttributes
301 public function testExpandAttributesSpaceSeparatedAttributesWithBoolean() {
303 ' class="booltrue one"',
304 Html
::expandAttributes( [ 'class' => [
308 # Method use isset() internally, make sure we do discard
309 # attributes values which have been assigned well known values
311 'boolfalse' => false,
319 * How do we handle duplicate keys in HTML attributes expansion?
320 * We could pass a "class" the values: 'GREEN' and array( 'GREEN' => false )
321 * The latter will take precedence.
323 * Feature added by r96188
324 * @covers Html::expandAttributes
326 public function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
329 Html
::expandAttributes( [ 'class' => [
338 * @covers Html::expandAttributes
339 * @expectedException MWException
341 public function testExpandAttributes_ArrayOnNonListValueAttribute_ThrowsException() {
342 // Real-life test case found in the Popups extension (see Gerrit cf0fd64),
343 // when used with an outdated BetaFeatures extension (see Gerrit deda1e7)
344 Html
::expandAttributes( [
353 * @covers Html::namespaceSelector
354 * @covers Html::namespaceSelectorOptions
356 public function testNamespaceSelector() {
358 '<select id="namespace" name="namespace">' . "\n" .
359 '<option value="0">(Principal)</option>' . "\n" .
360 '<option value="1">Talk</option>' . "\n" .
361 '<option value="2">User</option>' . "\n" .
362 '<option value="3">User talk</option>' . "\n" .
363 '<option value="4">MyWiki</option>' . "\n" .
364 '<option value="5">MyWiki Talk</option>' . "\n" .
365 '<option value="6">File</option>' . "\n" .
366 '<option value="7">File talk</option>' . "\n" .
367 '<option value="8">MediaWiki</option>' . "\n" .
368 '<option value="9">MediaWiki talk</option>' . "\n" .
369 '<option value="10">Template</option>' . "\n" .
370 '<option value="11">Template talk</option>' . "\n" .
371 '<option value="14">Category</option>' . "\n" .
372 '<option value="15">Category talk</option>' . "\n" .
373 '<option value="100">Custom</option>' . "\n" .
374 '<option value="101">Custom talk</option>' . "\n" .
376 Html
::namespaceSelector(),
377 'Basic namespace selector without custom options'
381 '<label for="mw-test-namespace">Select a namespace:</label>' . "\u{00A0}" .
382 '<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
383 '<option value="all">todos</option>' . "\n" .
384 '<option value="0">(Principal)</option>' . "\n" .
385 '<option value="1">Talk</option>' . "\n" .
386 '<option value="2" selected="">User</option>' . "\n" .
387 '<option value="3">User talk</option>' . "\n" .
388 '<option value="4">MyWiki</option>' . "\n" .
389 '<option value="5">MyWiki Talk</option>' . "\n" .
390 '<option value="6">File</option>' . "\n" .
391 '<option value="7">File talk</option>' . "\n" .
392 '<option value="8">MediaWiki</option>' . "\n" .
393 '<option value="9">MediaWiki talk</option>' . "\n" .
394 '<option value="10">Template</option>' . "\n" .
395 '<option value="11">Template talk</option>' . "\n" .
396 '<option value="14">Category</option>' . "\n" .
397 '<option value="15">Category talk</option>' . "\n" .
398 '<option value="100">Custom</option>' . "\n" .
399 '<option value="101">Custom talk</option>' . "\n" .
401 Html
::namespaceSelector(
402 [ 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ],
403 [ 'name' => 'wpNamespace', 'id' => 'mw-test-namespace' ]
405 'Basic namespace selector with custom values'
409 '<label for="namespace">Select a namespace:</label>' . "\u{00A0}" .
410 '<select id="namespace" name="namespace">' . "\n" .
411 '<option value="0">(Principal)</option>' . "\n" .
412 '<option value="1">Talk</option>' . "\n" .
413 '<option value="2">User</option>' . "\n" .
414 '<option value="3">User talk</option>' . "\n" .
415 '<option value="4">MyWiki</option>' . "\n" .
416 '<option value="5">MyWiki Talk</option>' . "\n" .
417 '<option value="6">File</option>' . "\n" .
418 '<option value="7">File talk</option>' . "\n" .
419 '<option value="8">MediaWiki</option>' . "\n" .
420 '<option value="9">MediaWiki talk</option>' . "\n" .
421 '<option value="10">Template</option>' . "\n" .
422 '<option value="11">Template talk</option>' . "\n" .
423 '<option value="14">Category</option>' . "\n" .
424 '<option value="15">Category talk</option>' . "\n" .
425 '<option value="100">Custom</option>' . "\n" .
426 '<option value="101">Custom talk</option>' . "\n" .
428 Html
::namespaceSelector(
429 [ 'label' => 'Select a namespace:' ]
431 'Basic namespace selector with a custom label but no id attribtue for the <select>'
435 '<select id="namespace" name="namespace">' . "\n" .
436 '<option value="0">(Principal)</option>' . "\n" .
437 '<option value="1">Discusión</option>' . "\n" .
438 '<option value="2">Usuario</option>' . "\n" .
439 '<option value="3">Usuario discusión</option>' . "\n" .
440 '<option value="4">Wiki</option>' . "\n" .
441 '<option value="5">Wiki discusión</option>' . "\n" .
442 '<option value="6">Archivo</option>' . "\n" .
443 '<option value="7">Archivo discusión</option>' . "\n" .
444 '<option value="8">MediaWiki</option>' . "\n" .
445 '<option value="9">MediaWiki discusión</option>' . "\n" .
446 '<option value="10">Plantilla</option>' . "\n" .
447 '<option value="11">Plantilla discusión</option>' . "\n" .
448 '<option value="12">Ayuda</option>' . "\n" .
449 '<option value="13">Ayuda discusión</option>' . "\n" .
450 '<option value="14">Categoría</option>' . "\n" .
451 '<option value="15">Categoría discusión</option>' . "\n" .
452 '<option value="100">Personalizado</option>' . "\n" .
453 '<option value="101">Personalizado discusión</option>' . "\n" .
455 Html
::namespaceSelector(
456 [ 'in-user-lang' => true ]
458 'Basic namespace selector in user language'
463 * @covers Html::namespaceSelector
465 public function testCanFilterOutNamespaces() {
467 '<select id="namespace" name="namespace">' . "\n" .
468 '<option value="2">User</option>' . "\n" .
469 '<option value="4">MyWiki</option>' . "\n" .
470 '<option value="5">MyWiki Talk</option>' . "\n" .
471 '<option value="6">File</option>' . "\n" .
472 '<option value="7">File talk</option>' . "\n" .
473 '<option value="8">MediaWiki</option>' . "\n" .
474 '<option value="9">MediaWiki talk</option>' . "\n" .
475 '<option value="10">Template</option>' . "\n" .
476 '<option value="11">Template talk</option>' . "\n" .
477 '<option value="14">Category</option>' . "\n" .
478 '<option value="15">Category talk</option>' . "\n" .
480 Html
::namespaceSelector(
481 [ 'exclude' => [ 0, 1, 3, 100, 101 ] ]
483 'Namespace selector namespace filtering.'
488 * @covers Html::namespaceSelector
490 public function testCanDisableANamespaces() {
492 '<select id="namespace" name="namespace">' . "\n" .
493 '<option disabled="" value="0">(Principal)</option>' . "\n" .
494 '<option disabled="" value="1">Talk</option>' . "\n" .
495 '<option disabled="" value="2">User</option>' . "\n" .
496 '<option disabled="" value="3">User talk</option>' . "\n" .
497 '<option disabled="" value="4">MyWiki</option>' . "\n" .
498 '<option value="5">MyWiki Talk</option>' . "\n" .
499 '<option value="6">File</option>' . "\n" .
500 '<option value="7">File talk</option>' . "\n" .
501 '<option value="8">MediaWiki</option>' . "\n" .
502 '<option value="9">MediaWiki talk</option>' . "\n" .
503 '<option value="10">Template</option>' . "\n" .
504 '<option value="11">Template talk</option>' . "\n" .
505 '<option value="14">Category</option>' . "\n" .
506 '<option value="15">Category talk</option>' . "\n" .
507 '<option value="100">Custom</option>' . "\n" .
508 '<option value="101">Custom talk</option>' . "\n" .
510 Html
::namespaceSelector( [
511 'disable' => [ 0, 1, 2, 3, 4 ]
513 'Namespace selector namespace disabling'
518 * @dataProvider provideHtml5InputTypes
519 * @covers Html::element
521 public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
523 '<input type="' . $HTML5InputType . '"/>',
524 Html
::element( 'input', [ 'type' => $HTML5InputType ] ),
525 'In HTML5, Html::element() should accept type="' . $HTML5InputType . '"'
530 * @covers Html::warningBox
531 * @covers Html::messageBox
533 public function testWarningBox() {
535 Html
::warningBox( 'warn' ),
536 '<div class="warningbox">warn</div>'
541 * @covers Html::errorBox
542 * @covers Html::messageBox
544 public function testErrorBox() {
546 Html
::errorBox( 'err' ),
547 '<div class="errorbox">err</div>'
550 Html
::errorBox( 'err', 'heading' ),
551 '<div class="errorbox"><h2>heading</h2>err</div>'
554 Html
::errorBox( 'err', '0' ),
555 '<div class="errorbox"><h2>0</h2>err</div>'
560 * @covers Html::successBox
561 * @covers Html::messageBox
563 public function testSuccessBox() {
565 Html
::successBox( 'great' ),
566 '<div class="successbox">great</div>'
569 Html
::successBox( '<script>beware no escaping!</script>' ),
570 '<div class="successbox"><script>beware no escaping!</script></div>'
575 * List of input element types values introduced by HTML5
576 * Full list at https://www.w3.org/TR/html-markup/input.html
578 public static function provideHtml5InputTypes() {
595 foreach ( $types as $type ) {
596 $cases[] = [ $type ];
603 * Test out Html::element drops or enforces default value
604 * @covers Html::dropDefaults
605 * @dataProvider provideElementsWithAttributesHavingDefaultValues
607 public function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
608 $this->assertEquals( $expected, Html
::element( $element, $attribs ), $message );
611 public static function provideElementsWithAttributesHavingDefaultValues() {
612 # Use cases in a concise format:
613 # <expected>, <element name>, <array of attributes> [, <message>]
614 # Will be mapped to Html::element()
617 # ## Generic cases, match $attribDefault static array
618 $cases[] = [ '<area/>',
619 'area', [ 'shape' => 'rect' ]
622 $cases[] = [ '<button type="submit"></button>',
623 'button', [ 'formaction' => 'GET' ]
625 $cases[] = [ '<button type="submit"></button>',
626 'button', [ 'formenctype' => 'application/x-www-form-urlencoded' ]
629 $cases[] = [ '<canvas></canvas>',
630 'canvas', [ 'height' => '150' ]
632 $cases[] = [ '<canvas></canvas>',
633 'canvas', [ 'width' => '300' ]
635 # Also check with numeric values
636 $cases[] = [ '<canvas></canvas>',
637 'canvas', [ 'height' => 150 ]
639 $cases[] = [ '<canvas></canvas>',
640 'canvas', [ 'width' => 300 ]
643 $cases[] = [ '<form></form>',
644 'form', [ 'action' => 'GET' ]
646 $cases[] = [ '<form></form>',
647 'form', [ 'autocomplete' => 'on' ]
649 $cases[] = [ '<form></form>',
650 'form', [ 'enctype' => 'application/x-www-form-urlencoded' ]
653 $cases[] = [ '<input/>',
654 'input', [ 'formaction' => 'GET' ]
656 $cases[] = [ '<input/>',
657 'input', [ 'type' => 'text' ]
660 $cases[] = [ '<keygen/>',
661 'keygen', [ 'keytype' => 'rsa' ]
664 $cases[] = [ '<link/>',
665 'link', [ 'media' => 'all' ]
668 $cases[] = [ '<menu></menu>',
669 'menu', [ 'type' => 'list' ]
672 $cases[] = [ '<script></script>',
673 'script', [ 'type' => 'text/javascript' ]
676 $cases[] = [ '<style></style>',
677 'style', [ 'media' => 'all' ]
679 $cases[] = [ '<style></style>',
680 'style', [ 'type' => 'text/css' ]
683 $cases[] = [ '<textarea></textarea>',
684 'textarea', [ 'wrap' => 'soft' ]
689 # <link type="text/css">
690 $cases[] = [ '<link/>',
691 'link', [ 'type' => 'text/css' ]
694 # <input> specific handling
695 $cases[] = [ '<input type="checkbox"/>',
696 'input', [ 'type' => 'checkbox', 'value' => 'on' ],
697 'Default value "on" is stripped of checkboxes',
699 $cases[] = [ '<input type="radio"/>',
700 'input', [ 'type' => 'radio', 'value' => 'on' ],
701 'Default value "on" is stripped of radio buttons',
703 $cases[] = [ '<input type="submit" value="Submit"/>',
704 'input', [ 'type' => 'submit', 'value' => 'Submit' ],
705 'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
707 $cases[] = [ '<input type="color"/>',
708 'input', [ 'type' => 'color', 'value' => '' ],
710 $cases[] = [ '<input type="range"/>',
711 'input', [ 'type' => 'range', 'value' => '' ],
714 # <button> specific handling
715 # see remarks on https://msdn.microsoft.com/library/ms535211(v=vs.85).aspx
716 $cases[] = [ '<button type="submit"></button>',
717 'button', [ 'type' => 'submit' ],
718 'According to standard the default type is "submit". '
719 . 'Depending on compatibility mode IE might use "button", instead.',
722 # <select> specific handling
723 $cases[] = [ '<select multiple=""></select>',
724 'select', [ 'size' => '4', 'multiple' => true ],
726 # .. with numeric value
727 $cases[] = [ '<select multiple=""></select>',
728 'select', [ 'size' => 4, 'multiple' => true ],
730 $cases[] = [ '<select></select>',
731 'select', [ 'size' => '1', 'multiple' => false ],
733 # .. with numeric value
734 $cases[] = [ '<select></select>',
735 'select', [ 'size' => 1, 'multiple' => false ],
738 # Passing an array as value
739 $cases[] = [ '<a class="css-class-one css-class-two"></a>',
740 'a', [ 'class' => [ 'css-class-one', 'css-class-two' ] ],
741 "dropDefaults accepts values given as an array"
744 # FIXME: doDropDefault should remove defaults given in an array
745 # Expected should be '<a></a>'
746 $cases[] = [ '<a class=""></a>',
747 'a', [ 'class' => [ '', '' ] ],
748 "dropDefaults accepts values given as an array"
751 # Craft the Html elements
753 foreach ( $cases as $case ) {
765 * @covers Html::input
767 public function testWrapperInput() {
769 '<input type="radio" value="testval" name="testname"/>',
770 Html
::input( 'testname', 'testval', 'radio' ),
771 'Input wrapper with type and value.'
774 '<input name="testname"/>',
775 Html
::input( 'testname' ),
776 'Input wrapper with all default values.'
781 * @covers Html::check
783 public function testWrapperCheck() {
785 '<input type="checkbox" value="1" name="testname"/>',
786 Html
::check( 'testname' ),
787 'Checkbox wrapper unchecked.'
790 '<input checked="" type="checkbox" value="1" name="testname"/>',
791 Html
::check( 'testname', true ),
792 'Checkbox wrapper checked.'
795 '<input type="checkbox" value="testval" name="testname"/>',
796 Html
::check( 'testname', false, [ 'value' => 'testval' ] ),
797 'Checkbox wrapper with a value override.'
802 * @covers Html::radio
804 public function testWrapperRadio() {
806 '<input type="radio" value="1" name="testname"/>',
807 Html
::radio( 'testname' ),
808 'Radio wrapper unchecked.'
811 '<input checked="" type="radio" value="1" name="testname"/>',
812 Html
::radio( 'testname', true ),
813 'Radio wrapper checked.'
816 '<input type="radio" value="testval" name="testname"/>',
817 Html
::radio( 'testname', false, [ 'value' => 'testval' ] ),
818 'Radio wrapper with a value override.'
823 * @covers Html::label
825 public function testWrapperLabel() {
827 '<label for="testid">testlabel</label>',
828 Html
::label( 'testlabel', 'testid' ),
833 public static function provideSrcSetImages() {
835 [ [], '', 'when there are no images, return empty string' ],
837 [ '1x' => '1x.png', '1.5x' => '1_5x.png', '2x' => '2x.png' ],
838 '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
839 'pixel depth keys may include a trailing "x"'
842 [ '1' => '1x.png', '1.5' => '1_5x.png', '2' => '2x.png' ],
843 '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
844 'pixel depth keys may omit a trailing "x"'
847 [ '1' => 'small.png', '1.5' => 'large.png', '2' => 'large.png' ],
848 'small.png 1x, large.png 1.5x',
849 'omit larger duplicates'
852 [ '1' => 'small.png', '2' => 'large.png', '1.5' => 'large.png' ],
853 'small.png 1x, large.png 1.5x',
854 'omit larger duplicates in irregular order'
860 * @dataProvider provideSrcSetImages
861 * @covers Html::srcSet
863 public function testSrcSet( $images, $expected, $message ) {
864 $this->assertEquals( Html
::srcSet( $images ), $expected, $message );
867 public static function provideInlineScript() {
874 'EXAMPLE.label("foo");',
875 '<script>EXAMPLE.label("foo");</script>'
878 'EXAMPLE.is(a && b);',
879 '<script>EXAMPLE.is(a && b);</script>'
882 'EXAMPLE.label("<a>");',
883 '<script>EXAMPLE.label("<a>");</script>'
885 'Script closing string (lower)' => [
886 'EXAMPLE.label("</script>");',
887 '<script>/* ERROR: Invalid script */</script>',
890 'Script closing with non-standard attributes (mixed)' => [
891 'EXAMPLE.label("</SCriPT and STyLE>");',
892 '<script>/* ERROR: Invalid script */</script>',
895 'HTML-comment-open and script-open' => [
896 // In HTML, <script> contents aren't just plain CDATA until </script>,
897 // there are levels of escaping modes, and the below sequence puts an
898 // HTML parser in a state where </script> would *not* close the script.
899 // https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escape-end-state
900 'var a = "<!--<script>";',
901 '<script>/* ERROR: Invalid script */</script>',
908 * @dataProvider provideInlineScript
909 * @covers Html::inlineScript
911 public function testInlineScript( $code, $expected, $error = false ) {
913 Wikimedia\
suppressWarnings();
914 $this->restoreWarnings
= true;
916 $this->assertSame( Html
::inlineScript( $code ), $expected );
920 class HtmlTestValue
{
921 function __toString() {
922 return 'stringValue';