MediaWiki  1.27.1
HtmlTest.php
Go to the documentation of this file.
1 <?php
4 class HtmlTest extends MediaWikiTestCase {
5 
6  protected function setUp() {
7  parent::setUp();
8 
9  $this->setMwGlobals( [
10  'wgUseMediaWikiUIEverywhere' => false,
11  ] );
12 
13  $langObj = Language::factory( 'en' );
14 
15  // Hardcode namespaces during test runs,
16  // so that html output based on existing namespaces
17  // can be properly evaluated.
18  $langObj->setNamespaces( [
19  -2 => 'Media',
20  -1 => 'Special',
21  0 => '',
22  1 => 'Talk',
23  2 => 'User',
24  3 => 'User_talk',
25  4 => 'MyWiki',
26  5 => 'MyWiki_Talk',
27  6 => 'File',
28  7 => 'File_talk',
29  8 => 'MediaWiki',
30  9 => 'MediaWiki_talk',
31  10 => 'Template',
32  11 => 'Template_talk',
33  14 => 'Category',
34  15 => 'Category_talk',
35  100 => 'Custom',
36  101 => 'Custom_talk',
37  ] );
38  $this->setUserLang( $langObj );
39  $this->setContentLang( $langObj );
40  }
41 
45  public function testElementBasics() {
46  $this->assertEquals(
47  '<img/>',
48  Html::element( 'img', null, '' ),
49  'No close tag for short-tag elements'
50  );
51 
52  $this->assertEquals(
53  '<element></element>',
54  Html::element( 'element', null, null ),
55  'Close tag for empty element (null, null)'
56  );
57 
58  $this->assertEquals(
59  '<element></element>',
60  Html::element( 'element', [], '' ),
61  'Close tag for empty element (array, string)'
62  );
63 
64  $this->assertEquals(
65  '<img/>',
66  Html::element( 'img', null, '' ),
67  'Self-closing tag for short-tag elements'
68  );
69  }
70 
71  public function dataXmlMimeType() {
72  return [
73  // ( $mimetype, $isXmlMimeType )
74  # HTML is not an XML MimeType
75  [ 'text/html', false ],
76  # XML is an XML MimeType
77  [ 'text/xml', true ],
78  [ 'application/xml', true ],
79  # XHTML is an XML MimeType
80  [ 'application/xhtml+xml', true ],
81  # Make sure other +xml MimeTypes are supported
82  # SVG is another random MimeType even though we don't use it
83  [ 'image/svg+xml', true ],
84  # Complete random other MimeTypes are not XML
85  [ 'text/plain', false ],
86  ];
87  }
88 
93  public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
94  $this->assertEquals( $isXmlMimeType, Html::isXmlMimeType( $mimetype ) );
95  }
96 
101 
102  # ## EMPTY ########
103  $this->assertEmpty(
104  Html::expandAttributes( [ 'foo' => null ] ),
105  'skip keys with null value'
106  );
107  $this->assertEmpty(
108  Html::expandAttributes( [ 'foo' => false ] ),
109  'skip keys with false value'
110  );
111  $this->assertEquals(
112  ' foo=""',
113  Html::expandAttributes( [ 'foo' => '' ] ),
114  'keep keys with an empty string'
115  );
116  }
117 
122  $this->assertEquals(
123  '',
124  Html::expandAttributes( [ 'selected' => false ] ),
125  'Boolean attributes do not generates output when value is false'
126  );
127  $this->assertEquals(
128  '',
129  Html::expandAttributes( [ 'selected' => null ] ),
130  'Boolean attributes do not generates output when value is null'
131  );
132 
133  $this->assertEquals(
134  ' selected=""',
135  Html::expandAttributes( [ 'selected' => true ] ),
136  'Boolean attributes have no value when value is true'
137  );
138  $this->assertEquals(
139  ' selected=""',
140  Html::expandAttributes( [ 'selected' ] ),
141  'Boolean attributes have no value when value is true (passed as numerical array)'
142  );
143 
144  $this->assertEquals(
145  ' selected=""',
146  Html::expandAttributes( [ 'selected' => true ] ),
147  'Boolean attributes have empty string value when value is true'
148  );
149  }
150 
154  public function testExpandAttributesForNumbers() {
155  $this->assertEquals(
156  ' value="1"',
157  Html::expandAttributes( [ 'value' => 1 ] ),
158  'Integer value is cast to a string'
159  );
160  $this->assertEquals(
161  ' value="1.1"',
162  Html::expandAttributes( [ 'value' => 1.1 ] ),
163  'Float value is cast to a string'
164  );
165  }
166 
170  public function testExpandAttributesForObjects() {
171  $this->assertEquals(
172  ' value="stringValue"',
173  Html::expandAttributes( [ 'value' => new HtmlTestValue() ] ),
174  'Object value is converted to a string'
175  );
176  }
177 
184  # ## NOT EMPTY ####
185  $this->assertEquals(
186  ' empty_string=""',
187  Html::expandAttributes( [ 'empty_string' => '' ] ),
188  'Empty string is always quoted'
189  );
190  $this->assertEquals(
191  ' key="value"',
192  Html::expandAttributes( [ 'key' => 'value' ] ),
193  'Simple string value needs no quotes'
194  );
195  $this->assertEquals(
196  ' one="1"',
197  Html::expandAttributes( [ 'one' => 1 ] ),
198  'Number 1 value needs no quotes'
199  );
200  $this->assertEquals(
201  ' zero="0"',
202  Html::expandAttributes( [ 'zero' => 0 ] ),
203  'Number 0 value needs no quotes'
204  );
205 
206  }
207 
215  # ## STRING VALUES
216  $this->assertEquals(
217  ' class="redundant spaces here"',
218  Html::expandAttributes( [ 'class' => ' redundant spaces here ' ] ),
219  'Normalization should strip redundant spaces'
220  );
221  $this->assertEquals(
222  ' class="foo bar"',
223  Html::expandAttributes( [ 'class' => 'foo bar foo bar bar' ] ),
224  'Normalization should remove duplicates in string-lists'
225  );
226  # ## "EMPTY" ARRAY VALUES
227  $this->assertEquals(
228  ' class=""',
229  Html::expandAttributes( [ 'class' => [] ] ),
230  'Value with an empty array'
231  );
232  $this->assertEquals(
233  ' class=""',
234  Html::expandAttributes( [ 'class' => [ null, '', ' ', ' ' ] ] ),
235  'Array with null, empty string and spaces'
236  );
237  # ## NON-EMPTY ARRAY VALUES
238  $this->assertEquals(
239  ' class="foo bar"',
240  Html::expandAttributes( [ 'class' => [
241  'foo',
242  'bar',
243  'foo',
244  'bar',
245  'bar',
246  ] ] ),
247  'Normalization should remove duplicates in the array'
248  );
249  $this->assertEquals(
250  ' class="foo bar"',
251  Html::expandAttributes( [ 'class' => [
252  'foo bar',
253  'bar foo',
254  'foo',
255  'bar bar',
256  ] ] ),
257  'Normalization should remove duplicates in string-lists in the array'
258  );
259  }
260 
267  $this->assertEquals(
268  ' class="booltrue one"',
269  Html::expandAttributes( [ 'class' => [
270  'booltrue' => true,
271  'one' => 1,
272 
273  # Method use isset() internally, make sure we do discard
274  # attributes values which have been assigned well known values
275  'emptystring' => '',
276  'boolfalse' => false,
277  'zero' => 0,
278  'null' => null,
279  ] ] )
280  );
281  }
282 
292  $this->assertEquals(
293  ' class=""',
294  Html::expandAttributes( [ 'class' => [
295  'GREEN',
296  'GREEN' => false,
297  'GREEN',
298  ] ] )
299  );
300  }
301 
307  // Real-life test case found in the Popups extension (see Gerrit cf0fd64),
308  // when used with an outdated BetaFeatures extension (see Gerrit deda1e7)
310  'src' => [
311  'ltr' => 'ltr.svg',
312  'rtl' => 'rtl.svg'
313  ]
314  ] );
315  }
316 
320  public function testNamespaceSelector() {
321  $this->assertEquals(
322  '<select id="namespace" name="namespace">' . "\n" .
323  '<option value="0">(Main)</option>' . "\n" .
324  '<option value="1">Talk</option>' . "\n" .
325  '<option value="2">User</option>' . "\n" .
326  '<option value="3">User talk</option>' . "\n" .
327  '<option value="4">MyWiki</option>' . "\n" .
328  '<option value="5">MyWiki Talk</option>' . "\n" .
329  '<option value="6">File</option>' . "\n" .
330  '<option value="7">File talk</option>' . "\n" .
331  '<option value="8">MediaWiki</option>' . "\n" .
332  '<option value="9">MediaWiki talk</option>' . "\n" .
333  '<option value="10">Template</option>' . "\n" .
334  '<option value="11">Template talk</option>' . "\n" .
335  '<option value="14">Category</option>' . "\n" .
336  '<option value="15">Category talk</option>' . "\n" .
337  '<option value="100">Custom</option>' . "\n" .
338  '<option value="101">Custom talk</option>' . "\n" .
339  '</select>',
341  'Basic namespace selector without custom options'
342  );
343 
344  $this->assertEquals(
345  '<label for="mw-test-namespace">Select a namespace:</label>&#160;' .
346  '<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
347  '<option value="all">all</option>' . "\n" .
348  '<option value="0">(Main)</option>' . "\n" .
349  '<option value="1">Talk</option>' . "\n" .
350  '<option value="2" selected="">User</option>' . "\n" .
351  '<option value="3">User talk</option>' . "\n" .
352  '<option value="4">MyWiki</option>' . "\n" .
353  '<option value="5">MyWiki Talk</option>' . "\n" .
354  '<option value="6">File</option>' . "\n" .
355  '<option value="7">File talk</option>' . "\n" .
356  '<option value="8">MediaWiki</option>' . "\n" .
357  '<option value="9">MediaWiki talk</option>' . "\n" .
358  '<option value="10">Template</option>' . "\n" .
359  '<option value="11">Template talk</option>' . "\n" .
360  '<option value="14">Category</option>' . "\n" .
361  '<option value="15">Category talk</option>' . "\n" .
362  '<option value="100">Custom</option>' . "\n" .
363  '<option value="101">Custom talk</option>' . "\n" .
364  '</select>',
366  [ 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ],
367  [ 'name' => 'wpNamespace', 'id' => 'mw-test-namespace' ]
368  ),
369  'Basic namespace selector with custom values'
370  );
371 
372  $this->assertEquals(
373  '<label for="namespace">Select a namespace:</label>&#160;' .
374  '<select id="namespace" name="namespace">' . "\n" .
375  '<option value="0">(Main)</option>' . "\n" .
376  '<option value="1">Talk</option>' . "\n" .
377  '<option value="2">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" .
391  '</select>',
393  [ 'label' => 'Select a namespace:' ]
394  ),
395  'Basic namespace selector with a custom label but no id attribtue for the <select>'
396  );
397  }
398 
399  public function testCanFilterOutNamespaces() {
400  $this->assertEquals(
401  '<select id="namespace" name="namespace">' . "\n" .
402  '<option value="2">User</option>' . "\n" .
403  '<option value="4">MyWiki</option>' . "\n" .
404  '<option value="5">MyWiki Talk</option>' . "\n" .
405  '<option value="6">File</option>' . "\n" .
406  '<option value="7">File talk</option>' . "\n" .
407  '<option value="8">MediaWiki</option>' . "\n" .
408  '<option value="9">MediaWiki talk</option>' . "\n" .
409  '<option value="10">Template</option>' . "\n" .
410  '<option value="11">Template talk</option>' . "\n" .
411  '<option value="14">Category</option>' . "\n" .
412  '<option value="15">Category talk</option>' . "\n" .
413  '</select>',
415  [ 'exclude' => [ 0, 1, 3, 100, 101 ] ]
416  ),
417  'Namespace selector namespace filtering.'
418  );
419  }
420 
421  public function testCanDisableANamespaces() {
422  $this->assertEquals(
423  '<select id="namespace" name="namespace">' . "\n" .
424  '<option disabled="" value="0">(Main)</option>' . "\n" .
425  '<option disabled="" value="1">Talk</option>' . "\n" .
426  '<option disabled="" value="2">User</option>' . "\n" .
427  '<option disabled="" value="3">User talk</option>' . "\n" .
428  '<option disabled="" value="4">MyWiki</option>' . "\n" .
429  '<option value="5">MyWiki Talk</option>' . "\n" .
430  '<option value="6">File</option>' . "\n" .
431  '<option value="7">File talk</option>' . "\n" .
432  '<option value="8">MediaWiki</option>' . "\n" .
433  '<option value="9">MediaWiki talk</option>' . "\n" .
434  '<option value="10">Template</option>' . "\n" .
435  '<option value="11">Template talk</option>' . "\n" .
436  '<option value="14">Category</option>' . "\n" .
437  '<option value="15">Category talk</option>' . "\n" .
438  '<option value="100">Custom</option>' . "\n" .
439  '<option value="101">Custom talk</option>' . "\n" .
440  '</select>',
442  'disable' => [ 0, 1, 2, 3, 4 ]
443  ] ),
444  'Namespace selector namespace disabling'
445  );
446  }
447 
452  public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
453  $this->assertEquals(
454  '<input type="' . $HTML5InputType . '"/>',
455  Html::element( 'input', [ 'type' => $HTML5InputType ] ),
456  'In HTML5, Html::element() should accept type="' . $HTML5InputType . '"'
457  );
458  }
459 
464  public static function provideHtml5InputTypes() {
465  $types = [
466  'datetime',
467  'datetime-local',
468  'date',
469  'month',
470  'time',
471  'week',
472  'number',
473  'range',
474  'email',
475  'url',
476  'search',
477  'tel',
478  'color',
479  ];
480  $cases = [];
481  foreach ( $types as $type ) {
482  $cases[] = [ $type ];
483  }
484 
485  return $cases;
486  }
487 
493  public function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
494  $this->assertEquals( $expected, Html::element( $element, $attribs ), $message );
495  }
496 
498  # Use cases in a concise format:
499  # <expected>, <element name>, <array of attributes> [, <message>]
500  # Will be mapped to Html::element()
501  $cases = [];
502 
503  # ## Generic cases, match $attribDefault static array
504  $cases[] = [ '<area/>',
505  'area', [ 'shape' => 'rect' ]
506  ];
507 
508  $cases[] = [ '<button type="submit"></button>',
509  'button', [ 'formaction' => 'GET' ]
510  ];
511  $cases[] = [ '<button type="submit"></button>',
512  'button', [ 'formenctype' => 'application/x-www-form-urlencoded' ]
513  ];
514 
515  $cases[] = [ '<canvas></canvas>',
516  'canvas', [ 'height' => '150' ]
517  ];
518  $cases[] = [ '<canvas></canvas>',
519  'canvas', [ 'width' => '300' ]
520  ];
521  # Also check with numeric values
522  $cases[] = [ '<canvas></canvas>',
523  'canvas', [ 'height' => 150 ]
524  ];
525  $cases[] = [ '<canvas></canvas>',
526  'canvas', [ 'width' => 300 ]
527  ];
528 
529  $cases[] = [ '<command/>',
530  'command', [ 'type' => 'command' ]
531  ];
532 
533  $cases[] = [ '<form></form>',
534  'form', [ 'action' => 'GET' ]
535  ];
536  $cases[] = [ '<form></form>',
537  'form', [ 'autocomplete' => 'on' ]
538  ];
539  $cases[] = [ '<form></form>',
540  'form', [ 'enctype' => 'application/x-www-form-urlencoded' ]
541  ];
542 
543  $cases[] = [ '<input/>',
544  'input', [ 'formaction' => 'GET' ]
545  ];
546  $cases[] = [ '<input/>',
547  'input', [ 'type' => 'text' ]
548  ];
549 
550  $cases[] = [ '<keygen/>',
551  'keygen', [ 'keytype' => 'rsa' ]
552  ];
553 
554  $cases[] = [ '<link/>',
555  'link', [ 'media' => 'all' ]
556  ];
557 
558  $cases[] = [ '<menu></menu>',
559  'menu', [ 'type' => 'list' ]
560  ];
561 
562  $cases[] = [ '<script></script>',
563  'script', [ 'type' => 'text/javascript' ]
564  ];
565 
566  $cases[] = [ '<style></style>',
567  'style', [ 'media' => 'all' ]
568  ];
569  $cases[] = [ '<style></style>',
570  'style', [ 'type' => 'text/css' ]
571  ];
572 
573  $cases[] = [ '<textarea></textarea>',
574  'textarea', [ 'wrap' => 'soft' ]
575  ];
576 
577  # ## SPECIFIC CASES
578 
579  # <link type="text/css">
580  $cases[] = [ '<link/>',
581  'link', [ 'type' => 'text/css' ]
582  ];
583 
584  # <input> specific handling
585  $cases[] = [ '<input type="checkbox"/>',
586  'input', [ 'type' => 'checkbox', 'value' => 'on' ],
587  'Default value "on" is stripped of checkboxes',
588  ];
589  $cases[] = [ '<input type="radio"/>',
590  'input', [ 'type' => 'radio', 'value' => 'on' ],
591  'Default value "on" is stripped of radio buttons',
592  ];
593  $cases[] = [ '<input type="submit" value="Submit"/>',
594  'input', [ 'type' => 'submit', 'value' => 'Submit' ],
595  'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
596  ];
597  $cases[] = [ '<input type="color"/>',
598  'input', [ 'type' => 'color', 'value' => '' ],
599  ];
600  $cases[] = [ '<input type="range"/>',
601  'input', [ 'type' => 'range', 'value' => '' ],
602  ];
603 
604  # <button> specific handling
605  # see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
606  $cases[] = [ '<button type="submit"></button>',
607  'button', [ 'type' => 'submit' ],
608  'According to standard the default type is "submit". '
609  . 'Depending on compatibility mode IE might use "button", instead.',
610  ];
611 
612  # <select> specific handling
613  $cases[] = [ '<select multiple=""></select>',
614  'select', [ 'size' => '4', 'multiple' => true ],
615  ];
616  # .. with numeric value
617  $cases[] = [ '<select multiple=""></select>',
618  'select', [ 'size' => 4, 'multiple' => true ],
619  ];
620  $cases[] = [ '<select></select>',
621  'select', [ 'size' => '1', 'multiple' => false ],
622  ];
623  # .. with numeric value
624  $cases[] = [ '<select></select>',
625  'select', [ 'size' => 1, 'multiple' => false ],
626  ];
627 
628  # Passing an array as value
629  $cases[] = [ '<a class="css-class-one css-class-two"></a>',
630  'a', [ 'class' => [ 'css-class-one', 'css-class-two' ] ],
631  "dropDefaults accepts values given as an array"
632  ];
633 
634  # FIXME: doDropDefault should remove defaults given in an array
635  # Expected should be '<a></a>'
636  $cases[] = [ '<a class=""></a>',
637  'a', [ 'class' => [ '', '' ] ],
638  "dropDefaults accepts values given as an array"
639  ];
640 
641  # Craft the Html elements
642  $ret = [];
643  foreach ( $cases as $case ) {
644  $ret[] = [
645  $case[0],
646  $case[1], $case[2],
647  isset( $case[3] ) ? $case[3] : ''
648  ];
649  }
650 
651  return $ret;
652  }
653 
657  public function testFormValidationBlacklist() {
658  $this->assertEmpty(
660  'min' => 1,
661  'max' => 100,
662  'pattern' => 'abc',
663  'required' => true,
664  'step' => 2
665  ] ),
666  'Blacklist form validation attributes.'
667  );
668  $this->assertEquals(
669  ' step="any"',
671  [
672  'min' => 1,
673  'max' => 100,
674  'pattern' => 'abc',
675  'required' => true,
676  'step' => 'any'
677  ],
678  'Allow special case "step=any".'
679  )
680  );
681  }
682 
683  public function testWrapperInput() {
684  $this->assertEquals(
685  '<input type="radio" value="testval" name="testname"/>',
686  Html::input( 'testname', 'testval', 'radio' ),
687  'Input wrapper with type and value.'
688  );
689  $this->assertEquals(
690  '<input name="testname"/>',
691  Html::input( 'testname' ),
692  'Input wrapper with all default values.'
693  );
694  }
695 
696  public function testWrapperCheck() {
697  $this->assertEquals(
698  '<input type="checkbox" value="1" name="testname"/>',
699  Html::check( 'testname' ),
700  'Checkbox wrapper unchecked.'
701  );
702  $this->assertEquals(
703  '<input checked="" type="checkbox" value="1" name="testname"/>',
704  Html::check( 'testname', true ),
705  'Checkbox wrapper checked.'
706  );
707  $this->assertEquals(
708  '<input type="checkbox" value="testval" name="testname"/>',
709  Html::check( 'testname', false, [ 'value' => 'testval' ] ),
710  'Checkbox wrapper with a value override.'
711  );
712  }
713 
714  public function testWrapperRadio() {
715  $this->assertEquals(
716  '<input type="radio" value="1" name="testname"/>',
717  Html::radio( 'testname' ),
718  'Radio wrapper unchecked.'
719  );
720  $this->assertEquals(
721  '<input checked="" type="radio" value="1" name="testname"/>',
722  Html::radio( 'testname', true ),
723  'Radio wrapper checked.'
724  );
725  $this->assertEquals(
726  '<input type="radio" value="testval" name="testname"/>',
727  Html::radio( 'testname', false, [ 'value' => 'testval' ] ),
728  'Radio wrapper with a value override.'
729  );
730  }
731 
732  public function testWrapperLabel() {
733  $this->assertEquals(
734  '<label for="testid">testlabel</label>',
735  Html::label( 'testlabel', 'testid' ),
736  'Label wrapper'
737  );
738  }
739 
740  public static function provideSrcSetImages() {
741  return [
742  [ [], '', 'when there are no images, return empty string' ],
743  [
744  [ '1x' => '1x.png', '1.5x' => '1_5x.png', '2x' => '2x.png' ],
745  '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
746  'pixel depth keys may include a trailing "x"'
747  ],
748  [
749  [ '1' => '1x.png', '1.5' => '1_5x.png', '2' => '2x.png' ],
750  '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
751  'pixel depth keys may omit a trailing "x"'
752  ],
753  ];
754  }
755 
760  public function testSrcSet( $images, $expected, $message ) {
761  $this->assertEquals( Html::srcSet( $images ), $expected, $message );
762  }
763 }
764 
766  function __toString() {
767  return 'stringValue';
768  }
769 }
testExpandAttributes_ArrayOnNonListValueAttribute_ThrowsException()
Html::expandAttributes MWException
Definition: HtmlTest.php:306
testWrapperCheck()
Definition: HtmlTest.php:696
testHtmlElementAcceptsNewHtml5TypesInHtml5Mode($HTML5InputType)
provideHtml5InputTypes Html::element
Definition: HtmlTest.php:452
testCanDisableANamespaces()
Definition: HtmlTest.php:421
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1798
static provideHtml5InputTypes()
List of input element types values introduced by HTML5 Full list at http://www.w3.org/TR/html-markup/input.html.
Definition: HtmlTest.php:464
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
testElementBasics()
Html::element.
Definition: HtmlTest.php:45
testXmlMimeType($mimetype, $isXmlMimeType)
dataXmlMimeType Html::isXmlMimeType
Definition: HtmlTest.php:93
page as well
testExpandAttributesVariousExpansions()
Test for Html::expandAttributes() Please note it output a string prefixed with a space! Html::expand...
Definition: HtmlTest.php:183
static radio($name, $checked=false, array $attribs=[])
Convenience function to produce a radio button (input element with type=radio)
Definition: Html.php:720
testCanFilterOutNamespaces()
Definition: HtmlTest.php:399
tests for includes/Html.php
Definition: HtmlTest.php:4
testFormValidationBlacklist()
Html::expandAttributes
Definition: HtmlTest.php:657
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1798
testExpandAttributesForNumbers()
Html::expandAttributes
Definition: HtmlTest.php:154
static check($name, $checked=false, array $attribs=[])
Convenience function to produce a checkbox (input element with type=checkbox)
Definition: Html.php:697
testExpandAttributesSpaceSeparatedAttributesWithBoolean()
Test feature added by r96188, let pass attributes values as a PHP array.
Definition: HtmlTest.php:266
testExpandAttributesListValueAttributes()
Html::expandAttributes has special features for HTML attributes that use space separated lists and al...
Definition: HtmlTest.php:214
testWrapperRadio()
Definition: HtmlTest.php:714
testExpandAttributesForObjects()
Html::expandAttributes
Definition: HtmlTest.php:170
static expandAttributes(array $attribs)
Given an associative array of element attributes, generate a string to stick after the element name i...
Definition: Html.php:472
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
testExpandAttributesForBooleans()
Html::expandAttributes
Definition: HtmlTest.php:121
testDropDefaults($expected, $element, $attribs, $message= '')
Test out Html::element drops or enforces default value Html::dropDefaults provideElementsWithAttrib...
Definition: HtmlTest.php:493
static srcSet(array $urls)
Generate a srcset attribute value.
Definition: Html.php:1030
dataXmlMimeType()
Definition: HtmlTest.php:71
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
testNamespaceSelector()
Html::namespaceSelector
Definition: HtmlTest.php:320
static input($name, $value= '', $type= 'text', array $attribs=[])
Convenience function to produce an "" element.
Definition: Html.php:676
testWrapperLabel()
Definition: HtmlTest.php:732
static isXmlMimeType($mimetype)
Determines if the given MIME type is xml.
Definition: Html.php:965
static provideSrcSetImages()
Definition: HtmlTest.php:740
!html< table >< tr >< td > broken</td ></tr ></table >!end!test Table cell attributes
testExpandAttributesSkipsNullAndFalse()
Html::expandAttributes
Definition: HtmlTest.php:100
testValueIsAuthoritativeInSpaceSeparatedAttributesArrays()
How do we handle duplicate keys in HTML attributes expansion? We could pass a "class" the values: 'GR...
Definition: HtmlTest.php:291
setUp()
Definition: HtmlTest.php:6
static factory($code)
Get a cached or new language object for a given language code.
Definition: Language.php:179
setMwGlobals($pairs, $value=null)
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
Definition: hooks.txt:177
testWrapperInput()
Definition: HtmlTest.php:683
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:230
testSrcSet($images, $expected, $message)
provideSrcSetImages Html::srcSet
Definition: HtmlTest.php:760
static provideElementsWithAttributesHavingDefaultValues()
Definition: HtmlTest.php:497
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2338
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1798
static label($label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
Definition: Html.php:743
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:847