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 * @covers Html::element
81 * @covers Html::rawElement
82 * @covers Html::openElement
83 * @covers Html::closeElement
85 public function testElementBasics() {
88 Html
::element( 'img', null, '' ),
89 'Self-closing tag for short-tag elements'
93 '<element></element>',
94 Html
::element( 'element', null, null ),
95 'Close tag for empty element (null, null)'
99 '<element></element>',
100 Html
::element( 'element', [], '' ),
101 'Close tag for empty element (array, string)'
105 public function dataXmlMimeType() {
107 // ( $mimetype, $isXmlMimeType )
108 # HTML is not an XML MimeType
109 [ 'text/html', false ],
110 # XML is an XML MimeType
111 [ 'text/xml', true ],
112 [ 'application/xml', true ],
113 # XHTML is an XML MimeType
114 [ 'application/xhtml+xml', true ],
115 # Make sure other +xml MimeTypes are supported
116 # SVG is another random MimeType even though we don't use it
117 [ 'image/svg+xml', true ],
118 # Complete random other MimeTypes are not XML
119 [ 'text/plain', false ],
124 * @dataProvider dataXmlMimeType
125 * @covers Html::isXmlMimeType
127 public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
128 $this->assertEquals( $isXmlMimeType, Html
::isXmlMimeType( $mimetype ) );
132 * @covers Html::expandAttributes
134 public function testExpandAttributesSkipsNullAndFalse() {
137 Html
::expandAttributes( [ 'foo' => null ] ),
138 'skip keys with null value'
141 Html
::expandAttributes( [ 'foo' => false ] ),
142 'skip keys with false value'
146 Html
::expandAttributes( [ 'foo' => '' ] ),
147 'keep keys with an empty string'
152 * @covers Html::expandAttributes
154 public function testExpandAttributesForBooleans() {
157 Html
::expandAttributes( [ 'selected' => false ] ),
158 'Boolean attributes do not generates output when value is false'
162 Html
::expandAttributes( [ 'selected' => null ] ),
163 'Boolean attributes do not generates output when value is null'
168 Html
::expandAttributes( [ 'selected' => true ] ),
169 'Boolean attributes have no value when value is true'
173 Html
::expandAttributes( [ 'selected' ] ),
174 'Boolean attributes have no value when value is true (passed as numerical array)'
179 * @covers Html::expandAttributes
181 public function testExpandAttributesForNumbers() {
184 Html
::expandAttributes( [ 'value' => 1 ] ),
185 'Integer value is cast to a string'
189 Html
::expandAttributes( [ 'value' => 1.1 ] ),
190 'Float value is cast to a string'
195 * @covers Html::expandAttributes
197 public function testExpandAttributesForObjects() {
199 ' value="stringValue"',
200 Html
::expandAttributes( [ 'value' => new HtmlTestValue() ] ),
201 'Object value is converted to a string'
206 * Test for Html::expandAttributes()
207 * Please note it output a string prefixed with a space!
208 * @covers Html::expandAttributes
210 public function testExpandAttributesVariousExpansions() {
214 Html
::expandAttributes( [ 'empty_string' => '' ] ),
215 'Empty string is always quoted'
219 Html
::expandAttributes( [ 'key' => 'value' ] ),
220 'Simple string value needs no quotes'
224 Html
::expandAttributes( [ 'one' => 1 ] ),
225 'Number 1 value needs no quotes'
229 Html
::expandAttributes( [ 'zero' => 0 ] ),
230 'Number 0 value needs no quotes'
235 * Html::expandAttributes has special features for HTML
236 * attributes that use space separated lists and also
237 * allows arrays to be used as values.
238 * @covers Html::expandAttributes
240 public function testExpandAttributesListValueAttributes() {
243 ' class="redundant spaces here"',
244 Html
::expandAttributes( [ 'class' => ' redundant spaces here ' ] ),
245 'Normalization should strip redundant spaces'
249 Html
::expandAttributes( [ 'class' => 'foo bar foo bar bar' ] ),
250 'Normalization should remove duplicates in string-lists'
252 # ## "EMPTY" ARRAY VALUES
255 Html
::expandAttributes( [ 'class' => [] ] ),
256 'Value with an empty array'
260 Html
::expandAttributes( [ 'class' => [ null, '', ' ', ' ' ] ] ),
261 'Array with null, empty string and spaces'
263 # ## NON-EMPTY ARRAY VALUES
266 Html
::expandAttributes( [ 'class' => [
273 'Normalization should remove duplicates in the array'
277 Html
::expandAttributes( [ 'class' => [
283 'Normalization should remove duplicates in string-lists in the array'
288 * Test feature added by r96188, let pass attributes values as
289 * a PHP array. Restricted to class,rel, accesskey.
290 * @covers Html::expandAttributes
292 public function testExpandAttributesSpaceSeparatedAttributesWithBoolean() {
294 ' class="booltrue one"',
295 Html
::expandAttributes( [ 'class' => [
299 # Method use isset() internally, make sure we do discard
300 # attributes values which have been assigned well known values
302 'boolfalse' => false,
310 * How do we handle duplicate keys in HTML attributes expansion?
311 * We could pass a "class" the values: 'GREEN' and array( 'GREEN' => false )
312 * The latter will take precedence.
314 * Feature added by r96188
315 * @covers Html::expandAttributes
317 public function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
320 Html
::expandAttributes( [ 'class' => [
329 * @covers Html::expandAttributes
330 * @expectedException MWException
332 public function testExpandAttributes_ArrayOnNonListValueAttribute_ThrowsException() {
333 // Real-life test case found in the Popups extension (see Gerrit cf0fd64),
334 // when used with an outdated BetaFeatures extension (see Gerrit deda1e7)
335 Html
::expandAttributes( [
344 * @covers Html::namespaceSelector
345 * @covers Html::namespaceSelectorOptions
347 public function testNamespaceSelector() {
349 '<select id="namespace" name="namespace">' . "\n" .
350 '<option value="0">(Principal)</option>' . "\n" .
351 '<option value="1">Talk</option>' . "\n" .
352 '<option value="2">User</option>' . "\n" .
353 '<option value="3">User talk</option>' . "\n" .
354 '<option value="4">MyWiki</option>' . "\n" .
355 '<option value="5">MyWiki Talk</option>' . "\n" .
356 '<option value="6">File</option>' . "\n" .
357 '<option value="7">File talk</option>' . "\n" .
358 '<option value="8">MediaWiki</option>' . "\n" .
359 '<option value="9">MediaWiki talk</option>' . "\n" .
360 '<option value="10">Template</option>' . "\n" .
361 '<option value="11">Template talk</option>' . "\n" .
362 '<option value="14">Category</option>' . "\n" .
363 '<option value="15">Category talk</option>' . "\n" .
364 '<option value="100">Custom</option>' . "\n" .
365 '<option value="101">Custom talk</option>' . "\n" .
367 Html
::namespaceSelector(),
368 'Basic namespace selector without custom options'
372 '<label for="mw-test-namespace">Select a namespace:</label>' . "\u{00A0}" .
373 '<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
374 '<option value="all">todos</option>' . "\n" .
375 '<option value="0">(Principal)</option>' . "\n" .
376 '<option value="1">Talk</option>' . "\n" .
377 '<option value="2" selected="">User</option>' . "\n" .
378 '<option value="3">User talk</option>' . "\n" .
379 '<option value="4">MyWiki</option>' . "\n" .
380 '<option value="5">MyWiki Talk</option>' . "\n" .
381 '<option value="6">File</option>' . "\n" .
382 '<option value="7">File talk</option>' . "\n" .
383 '<option value="8">MediaWiki</option>' . "\n" .
384 '<option value="9">MediaWiki talk</option>' . "\n" .
385 '<option value="10">Template</option>' . "\n" .
386 '<option value="11">Template talk</option>' . "\n" .
387 '<option value="14">Category</option>' . "\n" .
388 '<option value="15">Category talk</option>' . "\n" .
389 '<option value="100">Custom</option>' . "\n" .
390 '<option value="101">Custom talk</option>' . "\n" .
392 Html
::namespaceSelector(
393 [ 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ],
394 [ 'name' => 'wpNamespace', 'id' => 'mw-test-namespace' ]
396 'Basic namespace selector with custom values'
400 '<label for="namespace">Select a namespace:</label>' . "\u{00A0}" .
401 '<select id="namespace" name="namespace">' . "\n" .
402 '<option value="0">(Principal)</option>' . "\n" .
403 '<option value="1">Talk</option>' . "\n" .
404 '<option value="2">User</option>' . "\n" .
405 '<option value="3">User talk</option>' . "\n" .
406 '<option value="4">MyWiki</option>' . "\n" .
407 '<option value="5">MyWiki Talk</option>' . "\n" .
408 '<option value="6">File</option>' . "\n" .
409 '<option value="7">File talk</option>' . "\n" .
410 '<option value="8">MediaWiki</option>' . "\n" .
411 '<option value="9">MediaWiki talk</option>' . "\n" .
412 '<option value="10">Template</option>' . "\n" .
413 '<option value="11">Template talk</option>' . "\n" .
414 '<option value="14">Category</option>' . "\n" .
415 '<option value="15">Category talk</option>' . "\n" .
416 '<option value="100">Custom</option>' . "\n" .
417 '<option value="101">Custom talk</option>' . "\n" .
419 Html
::namespaceSelector(
420 [ 'label' => 'Select a namespace:' ]
422 'Basic namespace selector with a custom label but no id attribtue for the <select>'
426 '<select id="namespace" name="namespace">' . "\n" .
427 '<option value="0">(Principal)</option>' . "\n" .
428 '<option value="1">Discusión</option>' . "\n" .
429 '<option value="2">Usuario</option>' . "\n" .
430 '<option value="3">Usuario discusión</option>' . "\n" .
431 '<option value="4">Wiki</option>' . "\n" .
432 '<option value="5">Wiki discusión</option>' . "\n" .
433 '<option value="6">Archivo</option>' . "\n" .
434 '<option value="7">Archivo discusión</option>' . "\n" .
435 '<option value="8">MediaWiki</option>' . "\n" .
436 '<option value="9">MediaWiki discusión</option>' . "\n" .
437 '<option value="10">Plantilla</option>' . "\n" .
438 '<option value="11">Plantilla discusión</option>' . "\n" .
439 '<option value="12">Ayuda</option>' . "\n" .
440 '<option value="13">Ayuda discusión</option>' . "\n" .
441 '<option value="14">Categoría</option>' . "\n" .
442 '<option value="15">Categoría discusión</option>' . "\n" .
443 '<option value="100">Personalizado</option>' . "\n" .
444 '<option value="101">Personalizado discusión</option>' . "\n" .
446 Html
::namespaceSelector(
447 [ 'in-user-lang' => true ]
449 'Basic namespace selector in user language'
454 * @covers Html::namespaceSelector
456 public function testCanFilterOutNamespaces() {
458 '<select id="namespace" name="namespace">' . "\n" .
459 '<option value="2">User</option>' . "\n" .
460 '<option value="4">MyWiki</option>' . "\n" .
461 '<option value="5">MyWiki Talk</option>' . "\n" .
462 '<option value="6">File</option>' . "\n" .
463 '<option value="7">File talk</option>' . "\n" .
464 '<option value="8">MediaWiki</option>' . "\n" .
465 '<option value="9">MediaWiki talk</option>' . "\n" .
466 '<option value="10">Template</option>' . "\n" .
467 '<option value="11">Template talk</option>' . "\n" .
468 '<option value="14">Category</option>' . "\n" .
469 '<option value="15">Category talk</option>' . "\n" .
471 Html
::namespaceSelector(
472 [ 'exclude' => [ 0, 1, 3, 100, 101 ] ]
474 'Namespace selector namespace filtering.'
479 * @covers Html::namespaceSelector
481 public function testCanDisableANamespaces() {
483 '<select id="namespace" name="namespace">' . "\n" .
484 '<option disabled="" value="0">(Principal)</option>' . "\n" .
485 '<option disabled="" value="1">Talk</option>' . "\n" .
486 '<option disabled="" value="2">User</option>' . "\n" .
487 '<option disabled="" value="3">User talk</option>' . "\n" .
488 '<option disabled="" value="4">MyWiki</option>' . "\n" .
489 '<option value="5">MyWiki Talk</option>' . "\n" .
490 '<option value="6">File</option>' . "\n" .
491 '<option value="7">File talk</option>' . "\n" .
492 '<option value="8">MediaWiki</option>' . "\n" .
493 '<option value="9">MediaWiki talk</option>' . "\n" .
494 '<option value="10">Template</option>' . "\n" .
495 '<option value="11">Template talk</option>' . "\n" .
496 '<option value="14">Category</option>' . "\n" .
497 '<option value="15">Category talk</option>' . "\n" .
498 '<option value="100">Custom</option>' . "\n" .
499 '<option value="101">Custom talk</option>' . "\n" .
501 Html
::namespaceSelector( [
502 'disable' => [ 0, 1, 2, 3, 4 ]
504 'Namespace selector namespace disabling'
509 * @dataProvider provideHtml5InputTypes
510 * @covers Html::element
512 public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
514 '<input type="' . $HTML5InputType . '"/>',
515 Html
::element( 'input', [ 'type' => $HTML5InputType ] ),
516 'In HTML5, Html::element() should accept type="' . $HTML5InputType . '"'
521 * @covers Html::warningBox
522 * @covers Html::messageBox
524 public function testWarningBox() {
526 Html
::warningBox( 'warn' ),
527 '<div class="warningbox">warn</div>'
532 * @covers Html::errorBox
533 * @covers Html::messageBox
535 public function testErrorBox() {
537 Html
::errorBox( 'err' ),
538 '<div class="errorbox">err</div>'
541 Html
::errorBox( 'err', 'heading' ),
542 '<div class="errorbox"><h2>heading</h2>err</div>'
545 Html
::errorBox( 'err', '0' ),
546 '<div class="errorbox"><h2>0</h2>err</div>'
551 * @covers Html::successBox
552 * @covers Html::messageBox
554 public function testSuccessBox() {
556 Html
::successBox( 'great' ),
557 '<div class="successbox">great</div>'
560 Html
::successBox( '<script>beware no escaping!</script>' ),
561 '<div class="successbox"><script>beware no escaping!</script></div>'
566 * List of input element types values introduced by HTML5
567 * Full list at https://www.w3.org/TR/html-markup/input.html
569 public static function provideHtml5InputTypes() {
586 foreach ( $types as $type ) {
587 $cases[] = [ $type ];
594 * Test out Html::element drops or enforces default value
595 * @covers Html::dropDefaults
596 * @dataProvider provideElementsWithAttributesHavingDefaultValues
598 public function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
599 $this->assertEquals( $expected, Html
::element( $element, $attribs ), $message );
602 public static function provideElementsWithAttributesHavingDefaultValues() {
603 # Use cases in a concise format:
604 # <expected>, <element name>, <array of attributes> [, <message>]
605 # Will be mapped to Html::element()
608 # ## Generic cases, match $attribDefault static array
609 $cases[] = [ '<area/>',
610 'area', [ 'shape' => 'rect' ]
613 $cases[] = [ '<button type="submit"></button>',
614 'button', [ 'formaction' => 'GET' ]
616 $cases[] = [ '<button type="submit"></button>',
617 'button', [ 'formenctype' => 'application/x-www-form-urlencoded' ]
620 $cases[] = [ '<canvas></canvas>',
621 'canvas', [ 'height' => '150' ]
623 $cases[] = [ '<canvas></canvas>',
624 'canvas', [ 'width' => '300' ]
626 # Also check with numeric values
627 $cases[] = [ '<canvas></canvas>',
628 'canvas', [ 'height' => 150 ]
630 $cases[] = [ '<canvas></canvas>',
631 'canvas', [ 'width' => 300 ]
634 $cases[] = [ '<form></form>',
635 'form', [ 'action' => 'GET' ]
637 $cases[] = [ '<form></form>',
638 'form', [ 'autocomplete' => 'on' ]
640 $cases[] = [ '<form></form>',
641 'form', [ 'enctype' => 'application/x-www-form-urlencoded' ]
644 $cases[] = [ '<input/>',
645 'input', [ 'formaction' => 'GET' ]
647 $cases[] = [ '<input/>',
648 'input', [ 'type' => 'text' ]
651 $cases[] = [ '<keygen/>',
652 'keygen', [ 'keytype' => 'rsa' ]
655 $cases[] = [ '<link/>',
656 'link', [ 'media' => 'all' ]
659 $cases[] = [ '<menu></menu>',
660 'menu', [ 'type' => 'list' ]
663 $cases[] = [ '<script></script>',
664 'script', [ 'type' => 'text/javascript' ]
667 $cases[] = [ '<style></style>',
668 'style', [ 'media' => 'all' ]
670 $cases[] = [ '<style></style>',
671 'style', [ 'type' => 'text/css' ]
674 $cases[] = [ '<textarea></textarea>',
675 'textarea', [ 'wrap' => 'soft' ]
680 # <link type="text/css">
681 $cases[] = [ '<link/>',
682 'link', [ 'type' => 'text/css' ]
685 # <input> specific handling
686 $cases[] = [ '<input type="checkbox"/>',
687 'input', [ 'type' => 'checkbox', 'value' => 'on' ],
688 'Default value "on" is stripped of checkboxes',
690 $cases[] = [ '<input type="radio"/>',
691 'input', [ 'type' => 'radio', 'value' => 'on' ],
692 'Default value "on" is stripped of radio buttons',
694 $cases[] = [ '<input type="submit" value="Submit"/>',
695 'input', [ 'type' => 'submit', 'value' => 'Submit' ],
696 'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
698 $cases[] = [ '<input type="color"/>',
699 'input', [ 'type' => 'color', 'value' => '' ],
701 $cases[] = [ '<input type="range"/>',
702 'input', [ 'type' => 'range', 'value' => '' ],
705 # <button> specific handling
706 # see remarks on https://msdn.microsoft.com/library/ms535211(v=vs.85).aspx
707 $cases[] = [ '<button type="submit"></button>',
708 'button', [ 'type' => 'submit' ],
709 'According to standard the default type is "submit". '
710 . 'Depending on compatibility mode IE might use "button", instead.',
713 # <select> specific handling
714 $cases[] = [ '<select multiple=""></select>',
715 'select', [ 'size' => '4', 'multiple' => true ],
717 # .. with numeric value
718 $cases[] = [ '<select multiple=""></select>',
719 'select', [ 'size' => 4, 'multiple' => true ],
721 $cases[] = [ '<select></select>',
722 'select', [ 'size' => '1', 'multiple' => false ],
724 # .. with numeric value
725 $cases[] = [ '<select></select>',
726 'select', [ 'size' => 1, 'multiple' => false ],
729 # Passing an array as value
730 $cases[] = [ '<a class="css-class-one css-class-two"></a>',
731 'a', [ 'class' => [ 'css-class-one', 'css-class-two' ] ],
732 "dropDefaults accepts values given as an array"
735 # FIXME: doDropDefault should remove defaults given in an array
736 # Expected should be '<a></a>'
737 $cases[] = [ '<a class=""></a>',
738 'a', [ 'class' => [ '', '' ] ],
739 "dropDefaults accepts values given as an array"
742 # Craft the Html elements
744 foreach ( $cases as $case ) {
756 * @covers Html::input
758 public function testWrapperInput() {
760 '<input type="radio" value="testval" name="testname"/>',
761 Html
::input( 'testname', 'testval', 'radio' ),
762 'Input wrapper with type and value.'
765 '<input name="testname"/>',
766 Html
::input( 'testname' ),
767 'Input wrapper with all default values.'
772 * @covers Html::check
774 public function testWrapperCheck() {
776 '<input type="checkbox" value="1" name="testname"/>',
777 Html
::check( 'testname' ),
778 'Checkbox wrapper unchecked.'
781 '<input checked="" type="checkbox" value="1" name="testname"/>',
782 Html
::check( 'testname', true ),
783 'Checkbox wrapper checked.'
786 '<input type="checkbox" value="testval" name="testname"/>',
787 Html
::check( 'testname', false, [ 'value' => 'testval' ] ),
788 'Checkbox wrapper with a value override.'
793 * @covers Html::radio
795 public function testWrapperRadio() {
797 '<input type="radio" value="1" name="testname"/>',
798 Html
::radio( 'testname' ),
799 'Radio wrapper unchecked.'
802 '<input checked="" type="radio" value="1" name="testname"/>',
803 Html
::radio( 'testname', true ),
804 'Radio wrapper checked.'
807 '<input type="radio" value="testval" name="testname"/>',
808 Html
::radio( 'testname', false, [ 'value' => 'testval' ] ),
809 'Radio wrapper with a value override.'
814 * @covers Html::label
816 public function testWrapperLabel() {
818 '<label for="testid">testlabel</label>',
819 Html
::label( 'testlabel', 'testid' ),
824 public static function provideSrcSetImages() {
826 [ [], '', 'when there are no images, return empty string' ],
828 [ '1x' => '1x.png', '1.5x' => '1_5x.png', '2x' => '2x.png' ],
829 '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
830 'pixel depth keys may include a trailing "x"'
833 [ '1' => '1x.png', '1.5' => '1_5x.png', '2' => '2x.png' ],
834 '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
835 'pixel depth keys may omit a trailing "x"'
838 [ '1' => 'small.png', '1.5' => 'large.png', '2' => 'large.png' ],
839 'small.png 1x, large.png 1.5x',
840 'omit larger duplicates'
843 [ '1' => 'small.png', '2' => 'large.png', '1.5' => 'large.png' ],
844 'small.png 1x, large.png 1.5x',
845 'omit larger duplicates in irregular order'
851 * @dataProvider provideSrcSetImages
852 * @covers Html::srcSet
854 public function testSrcSet( $images, $expected, $message ) {
855 $this->assertEquals( Html
::srcSet( $images ), $expected, $message );
858 public static function provideInlineScript() {
865 'EXAMPLE.label("foo");',
866 '<script>EXAMPLE.label("foo");</script>'
869 'EXAMPLE.is(a && b);',
870 '<script>EXAMPLE.is(a && b);</script>'
873 'EXAMPLE.label("<a>");',
874 '<script>EXAMPLE.label("<a>");</script>'
876 'Script closing string (lower)' => [
877 'EXAMPLE.label("</script>");',
878 '<script>/* ERROR: Invalid script */</script>',
881 'Script closing with non-standard attributes (mixed)' => [
882 'EXAMPLE.label("</SCriPT and STyLE>");',
883 '<script>/* ERROR: Invalid script */</script>',
886 'HTML-comment-open and script-open' => [
887 // In HTML, <script> contents aren't just plain CDATA until </script>,
888 // there are levels of escaping modes, and the below sequence puts an
889 // HTML parser in a state where </script> would *not* close the script.
890 // https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escape-end-state
891 'var a = "<!--<script>";',
892 '<script>/* ERROR: Invalid script */</script>',
899 * @dataProvider provideInlineScript
900 * @covers Html::inlineScript
902 public function testInlineScript( $code, $expected, $error = false ) {
904 Wikimedia\
suppressWarnings();
905 $this->restoreWarnings
= true;
907 $this->assertSame( Html
::inlineScript( $code ), $expected );
911 class HtmlTestValue
{
912 function __toString() {
913 return 'stringValue';