MediaWiki  1.28.0
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  'Self-closing 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 
65  public function dataXmlMimeType() {
66  return [
67  // ( $mimetype, $isXmlMimeType )
68  # HTML is not an XML MimeType
69  [ 'text/html', false ],
70  # XML is an XML MimeType
71  [ 'text/xml', true ],
72  [ 'application/xml', true ],
73  # XHTML is an XML MimeType
74  [ 'application/xhtml+xml', true ],
75  # Make sure other +xml MimeTypes are supported
76  # SVG is another random MimeType even though we don't use it
77  [ 'image/svg+xml', true ],
78  # Complete random other MimeTypes are not XML
79  [ 'text/plain', false ],
80  ];
81  }
82 
87  public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
88  $this->assertEquals( $isXmlMimeType, Html::isXmlMimeType( $mimetype ) );
89  }
90 
95 
96  # ## EMPTY ########
97  $this->assertEmpty(
98  Html::expandAttributes( [ 'foo' => null ] ),
99  'skip keys with null value'
100  );
101  $this->assertEmpty(
102  Html::expandAttributes( [ 'foo' => false ] ),
103  'skip keys with false value'
104  );
105  $this->assertEquals(
106  ' foo=""',
107  Html::expandAttributes( [ 'foo' => '' ] ),
108  'keep keys with an empty string'
109  );
110  }
111 
116  $this->assertEquals(
117  '',
118  Html::expandAttributes( [ 'selected' => false ] ),
119  'Boolean attributes do not generates output when value is false'
120  );
121  $this->assertEquals(
122  '',
123  Html::expandAttributes( [ 'selected' => null ] ),
124  'Boolean attributes do not generates output when value is null'
125  );
126 
127  $this->assertEquals(
128  ' selected=""',
129  Html::expandAttributes( [ 'selected' => true ] ),
130  'Boolean attributes have no value when value is true'
131  );
132  $this->assertEquals(
133  ' selected=""',
134  Html::expandAttributes( [ 'selected' ] ),
135  'Boolean attributes have no value when value is true (passed as numerical array)'
136  );
137  }
138 
142  public function testExpandAttributesForNumbers() {
143  $this->assertEquals(
144  ' value="1"',
145  Html::expandAttributes( [ 'value' => 1 ] ),
146  'Integer value is cast to a string'
147  );
148  $this->assertEquals(
149  ' value="1.1"',
150  Html::expandAttributes( [ 'value' => 1.1 ] ),
151  'Float value is cast to a string'
152  );
153  }
154 
158  public function testExpandAttributesForObjects() {
159  $this->assertEquals(
160  ' value="stringValue"',
161  Html::expandAttributes( [ 'value' => new HtmlTestValue() ] ),
162  'Object value is converted to a string'
163  );
164  }
165 
172  # ## NOT EMPTY ####
173  $this->assertEquals(
174  ' empty_string=""',
175  Html::expandAttributes( [ 'empty_string' => '' ] ),
176  'Empty string is always quoted'
177  );
178  $this->assertEquals(
179  ' key="value"',
180  Html::expandAttributes( [ 'key' => 'value' ] ),
181  'Simple string value needs no quotes'
182  );
183  $this->assertEquals(
184  ' one="1"',
185  Html::expandAttributes( [ 'one' => 1 ] ),
186  'Number 1 value needs no quotes'
187  );
188  $this->assertEquals(
189  ' zero="0"',
190  Html::expandAttributes( [ 'zero' => 0 ] ),
191  'Number 0 value needs no quotes'
192  );
193 
194  }
195 
203  # ## STRING VALUES
204  $this->assertEquals(
205  ' class="redundant spaces here"',
206  Html::expandAttributes( [ 'class' => ' redundant spaces here ' ] ),
207  'Normalization should strip redundant spaces'
208  );
209  $this->assertEquals(
210  ' class="foo bar"',
211  Html::expandAttributes( [ 'class' => 'foo bar foo bar bar' ] ),
212  'Normalization should remove duplicates in string-lists'
213  );
214  # ## "EMPTY" ARRAY VALUES
215  $this->assertEquals(
216  ' class=""',
217  Html::expandAttributes( [ 'class' => [] ] ),
218  'Value with an empty array'
219  );
220  $this->assertEquals(
221  ' class=""',
222  Html::expandAttributes( [ 'class' => [ null, '', ' ', ' ' ] ] ),
223  'Array with null, empty string and spaces'
224  );
225  # ## NON-EMPTY ARRAY VALUES
226  $this->assertEquals(
227  ' class="foo bar"',
228  Html::expandAttributes( [ 'class' => [
229  'foo',
230  'bar',
231  'foo',
232  'bar',
233  'bar',
234  ] ] ),
235  'Normalization should remove duplicates in the array'
236  );
237  $this->assertEquals(
238  ' class="foo bar"',
239  Html::expandAttributes( [ 'class' => [
240  'foo bar',
241  'bar foo',
242  'foo',
243  'bar bar',
244  ] ] ),
245  'Normalization should remove duplicates in string-lists in the array'
246  );
247  }
248 
255  $this->assertEquals(
256  ' class="booltrue one"',
257  Html::expandAttributes( [ 'class' => [
258  'booltrue' => true,
259  'one' => 1,
260 
261  # Method use isset() internally, make sure we do discard
262  # attributes values which have been assigned well known values
263  'emptystring' => '',
264  'boolfalse' => false,
265  'zero' => 0,
266  'null' => null,
267  ] ] )
268  );
269  }
270 
280  $this->assertEquals(
281  ' class=""',
282  Html::expandAttributes( [ 'class' => [
283  'GREEN',
284  'GREEN' => false,
285  'GREEN',
286  ] ] )
287  );
288  }
289 
295  // Real-life test case found in the Popups extension (see Gerrit cf0fd64),
296  // when used with an outdated BetaFeatures extension (see Gerrit deda1e7)
298  'src' => [
299  'ltr' => 'ltr.svg',
300  'rtl' => 'rtl.svg'
301  ]
302  ] );
303  }
304 
308  public function testNamespaceSelector() {
309  $this->assertEquals(
310  '<select id="namespace" name="namespace">' . "\n" .
311  '<option value="0">(Main)</option>' . "\n" .
312  '<option value="1">Talk</option>' . "\n" .
313  '<option value="2">User</option>' . "\n" .
314  '<option value="3">User talk</option>' . "\n" .
315  '<option value="4">MyWiki</option>' . "\n" .
316  '<option value="5">MyWiki Talk</option>' . "\n" .
317  '<option value="6">File</option>' . "\n" .
318  '<option value="7">File talk</option>' . "\n" .
319  '<option value="8">MediaWiki</option>' . "\n" .
320  '<option value="9">MediaWiki talk</option>' . "\n" .
321  '<option value="10">Template</option>' . "\n" .
322  '<option value="11">Template talk</option>' . "\n" .
323  '<option value="14">Category</option>' . "\n" .
324  '<option value="15">Category talk</option>' . "\n" .
325  '<option value="100">Custom</option>' . "\n" .
326  '<option value="101">Custom talk</option>' . "\n" .
327  '</select>',
329  'Basic namespace selector without custom options'
330  );
331 
332  $this->assertEquals(
333  '<label for="mw-test-namespace">Select a namespace:</label>&#160;' .
334  '<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
335  '<option value="all">all</option>' . "\n" .
336  '<option value="0">(Main)</option>' . "\n" .
337  '<option value="1">Talk</option>' . "\n" .
338  '<option value="2" selected="">User</option>' . "\n" .
339  '<option value="3">User talk</option>' . "\n" .
340  '<option value="4">MyWiki</option>' . "\n" .
341  '<option value="5">MyWiki Talk</option>' . "\n" .
342  '<option value="6">File</option>' . "\n" .
343  '<option value="7">File talk</option>' . "\n" .
344  '<option value="8">MediaWiki</option>' . "\n" .
345  '<option value="9">MediaWiki talk</option>' . "\n" .
346  '<option value="10">Template</option>' . "\n" .
347  '<option value="11">Template talk</option>' . "\n" .
348  '<option value="14">Category</option>' . "\n" .
349  '<option value="15">Category talk</option>' . "\n" .
350  '<option value="100">Custom</option>' . "\n" .
351  '<option value="101">Custom talk</option>' . "\n" .
352  '</select>',
354  [ 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ],
355  [ 'name' => 'wpNamespace', 'id' => 'mw-test-namespace' ]
356  ),
357  'Basic namespace selector with custom values'
358  );
359 
360  $this->assertEquals(
361  '<label for="namespace">Select a namespace:</label>&#160;' .
362  '<select id="namespace" name="namespace">' . "\n" .
363  '<option value="0">(Main)</option>' . "\n" .
364  '<option value="1">Talk</option>' . "\n" .
365  '<option value="2">User</option>' . "\n" .
366  '<option value="3">User talk</option>' . "\n" .
367  '<option value="4">MyWiki</option>' . "\n" .
368  '<option value="5">MyWiki Talk</option>' . "\n" .
369  '<option value="6">File</option>' . "\n" .
370  '<option value="7">File talk</option>' . "\n" .
371  '<option value="8">MediaWiki</option>' . "\n" .
372  '<option value="9">MediaWiki talk</option>' . "\n" .
373  '<option value="10">Template</option>' . "\n" .
374  '<option value="11">Template talk</option>' . "\n" .
375  '<option value="14">Category</option>' . "\n" .
376  '<option value="15">Category talk</option>' . "\n" .
377  '<option value="100">Custom</option>' . "\n" .
378  '<option value="101">Custom talk</option>' . "\n" .
379  '</select>',
381  [ 'label' => 'Select a namespace:' ]
382  ),
383  'Basic namespace selector with a custom label but no id attribtue for the <select>'
384  );
385  }
386 
387  public function testCanFilterOutNamespaces() {
388  $this->assertEquals(
389  '<select id="namespace" name="namespace">' . "\n" .
390  '<option value="2">User</option>' . "\n" .
391  '<option value="4">MyWiki</option>' . "\n" .
392  '<option value="5">MyWiki Talk</option>' . "\n" .
393  '<option value="6">File</option>' . "\n" .
394  '<option value="7">File talk</option>' . "\n" .
395  '<option value="8">MediaWiki</option>' . "\n" .
396  '<option value="9">MediaWiki talk</option>' . "\n" .
397  '<option value="10">Template</option>' . "\n" .
398  '<option value="11">Template talk</option>' . "\n" .
399  '<option value="14">Category</option>' . "\n" .
400  '<option value="15">Category talk</option>' . "\n" .
401  '</select>',
403  [ 'exclude' => [ 0, 1, 3, 100, 101 ] ]
404  ),
405  'Namespace selector namespace filtering.'
406  );
407  }
408 
409  public function testCanDisableANamespaces() {
410  $this->assertEquals(
411  '<select id="namespace" name="namespace">' . "\n" .
412  '<option disabled="" value="0">(Main)</option>' . "\n" .
413  '<option disabled="" value="1">Talk</option>' . "\n" .
414  '<option disabled="" value="2">User</option>' . "\n" .
415  '<option disabled="" value="3">User talk</option>' . "\n" .
416  '<option disabled="" value="4">MyWiki</option>' . "\n" .
417  '<option value="5">MyWiki Talk</option>' . "\n" .
418  '<option value="6">File</option>' . "\n" .
419  '<option value="7">File talk</option>' . "\n" .
420  '<option value="8">MediaWiki</option>' . "\n" .
421  '<option value="9">MediaWiki talk</option>' . "\n" .
422  '<option value="10">Template</option>' . "\n" .
423  '<option value="11">Template talk</option>' . "\n" .
424  '<option value="14">Category</option>' . "\n" .
425  '<option value="15">Category talk</option>' . "\n" .
426  '<option value="100">Custom</option>' . "\n" .
427  '<option value="101">Custom talk</option>' . "\n" .
428  '</select>',
430  'disable' => [ 0, 1, 2, 3, 4 ]
431  ] ),
432  'Namespace selector namespace disabling'
433  );
434  }
435 
440  public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
441  $this->assertEquals(
442  '<input type="' . $HTML5InputType . '"/>',
443  Html::element( 'input', [ 'type' => $HTML5InputType ] ),
444  'In HTML5, Html::element() should accept type="' . $HTML5InputType . '"'
445  );
446  }
447 
452  public static function provideHtml5InputTypes() {
453  $types = [
454  'datetime',
455  'datetime-local',
456  'date',
457  'month',
458  'time',
459  'week',
460  'number',
461  'range',
462  'email',
463  'url',
464  'search',
465  'tel',
466  'color',
467  ];
468  $cases = [];
469  foreach ( $types as $type ) {
470  $cases[] = [ $type ];
471  }
472 
473  return $cases;
474  }
475 
481  public function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
482  $this->assertEquals( $expected, Html::element( $element, $attribs ), $message );
483  }
484 
486  # Use cases in a concise format:
487  # <expected>, <element name>, <array of attributes> [, <message>]
488  # Will be mapped to Html::element()
489  $cases = [];
490 
491  # ## Generic cases, match $attribDefault static array
492  $cases[] = [ '<area/>',
493  'area', [ 'shape' => 'rect' ]
494  ];
495 
496  $cases[] = [ '<button type="submit"></button>',
497  'button', [ 'formaction' => 'GET' ]
498  ];
499  $cases[] = [ '<button type="submit"></button>',
500  'button', [ 'formenctype' => 'application/x-www-form-urlencoded' ]
501  ];
502 
503  $cases[] = [ '<canvas></canvas>',
504  'canvas', [ 'height' => '150' ]
505  ];
506  $cases[] = [ '<canvas></canvas>',
507  'canvas', [ 'width' => '300' ]
508  ];
509  # Also check with numeric values
510  $cases[] = [ '<canvas></canvas>',
511  'canvas', [ 'height' => 150 ]
512  ];
513  $cases[] = [ '<canvas></canvas>',
514  'canvas', [ 'width' => 300 ]
515  ];
516 
517  $cases[] = [ '<form></form>',
518  'form', [ 'action' => 'GET' ]
519  ];
520  $cases[] = [ '<form></form>',
521  'form', [ 'autocomplete' => 'on' ]
522  ];
523  $cases[] = [ '<form></form>',
524  'form', [ 'enctype' => 'application/x-www-form-urlencoded' ]
525  ];
526 
527  $cases[] = [ '<input/>',
528  'input', [ 'formaction' => 'GET' ]
529  ];
530  $cases[] = [ '<input/>',
531  'input', [ 'type' => 'text' ]
532  ];
533 
534  $cases[] = [ '<keygen/>',
535  'keygen', [ 'keytype' => 'rsa' ]
536  ];
537 
538  $cases[] = [ '<link/>',
539  'link', [ 'media' => 'all' ]
540  ];
541 
542  $cases[] = [ '<menu></menu>',
543  'menu', [ 'type' => 'list' ]
544  ];
545 
546  $cases[] = [ '<script></script>',
547  'script', [ 'type' => 'text/javascript' ]
548  ];
549 
550  $cases[] = [ '<style></style>',
551  'style', [ 'media' => 'all' ]
552  ];
553  $cases[] = [ '<style></style>',
554  'style', [ 'type' => 'text/css' ]
555  ];
556 
557  $cases[] = [ '<textarea></textarea>',
558  'textarea', [ 'wrap' => 'soft' ]
559  ];
560 
561  # ## SPECIFIC CASES
562 
563  # <link type="text/css">
564  $cases[] = [ '<link/>',
565  'link', [ 'type' => 'text/css' ]
566  ];
567 
568  # <input> specific handling
569  $cases[] = [ '<input type="checkbox"/>',
570  'input', [ 'type' => 'checkbox', 'value' => 'on' ],
571  'Default value "on" is stripped of checkboxes',
572  ];
573  $cases[] = [ '<input type="radio"/>',
574  'input', [ 'type' => 'radio', 'value' => 'on' ],
575  'Default value "on" is stripped of radio buttons',
576  ];
577  $cases[] = [ '<input type="submit" value="Submit"/>',
578  'input', [ 'type' => 'submit', 'value' => 'Submit' ],
579  'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
580  ];
581  $cases[] = [ '<input type="color"/>',
582  'input', [ 'type' => 'color', 'value' => '' ],
583  ];
584  $cases[] = [ '<input type="range"/>',
585  'input', [ 'type' => 'range', 'value' => '' ],
586  ];
587 
588  # <button> specific handling
589  # see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
590  $cases[] = [ '<button type="submit"></button>',
591  'button', [ 'type' => 'submit' ],
592  'According to standard the default type is "submit". '
593  . 'Depending on compatibility mode IE might use "button", instead.',
594  ];
595 
596  # <select> specific handling
597  $cases[] = [ '<select multiple=""></select>',
598  'select', [ 'size' => '4', 'multiple' => true ],
599  ];
600  # .. with numeric value
601  $cases[] = [ '<select multiple=""></select>',
602  'select', [ 'size' => 4, 'multiple' => true ],
603  ];
604  $cases[] = [ '<select></select>',
605  'select', [ 'size' => '1', 'multiple' => false ],
606  ];
607  # .. with numeric value
608  $cases[] = [ '<select></select>',
609  'select', [ 'size' => 1, 'multiple' => false ],
610  ];
611 
612  # Passing an array as value
613  $cases[] = [ '<a class="css-class-one css-class-two"></a>',
614  'a', [ 'class' => [ 'css-class-one', 'css-class-two' ] ],
615  "dropDefaults accepts values given as an array"
616  ];
617 
618  # FIXME: doDropDefault should remove defaults given in an array
619  # Expected should be '<a></a>'
620  $cases[] = [ '<a class=""></a>',
621  'a', [ 'class' => [ '', '' ] ],
622  "dropDefaults accepts values given as an array"
623  ];
624 
625  # Craft the Html elements
626  $ret = [];
627  foreach ( $cases as $case ) {
628  $ret[] = [
629  $case[0],
630  $case[1], $case[2],
631  isset( $case[3] ) ? $case[3] : ''
632  ];
633  }
634 
635  return $ret;
636  }
637 
641  public function testFormValidationBlacklist() {
642  $this->assertEmpty(
644  'min' => 1,
645  'max' => 100,
646  'pattern' => 'abc',
647  'required' => true,
648  'step' => 2
649  ] ),
650  'Blacklist form validation attributes.'
651  );
652  $this->assertEquals(
653  ' step="any"',
655  [
656  'min' => 1,
657  'max' => 100,
658  'pattern' => 'abc',
659  'required' => true,
660  'step' => 'any'
661  ],
662  'Allow special case "step=any".'
663  )
664  );
665  }
666 
667  public function testWrapperInput() {
668  $this->assertEquals(
669  '<input type="radio" value="testval" name="testname"/>',
670  Html::input( 'testname', 'testval', 'radio' ),
671  'Input wrapper with type and value.'
672  );
673  $this->assertEquals(
674  '<input name="testname"/>',
675  Html::input( 'testname' ),
676  'Input wrapper with all default values.'
677  );
678  }
679 
680  public function testWrapperCheck() {
681  $this->assertEquals(
682  '<input type="checkbox" value="1" name="testname"/>',
683  Html::check( 'testname' ),
684  'Checkbox wrapper unchecked.'
685  );
686  $this->assertEquals(
687  '<input checked="" type="checkbox" value="1" name="testname"/>',
688  Html::check( 'testname', true ),
689  'Checkbox wrapper checked.'
690  );
691  $this->assertEquals(
692  '<input type="checkbox" value="testval" name="testname"/>',
693  Html::check( 'testname', false, [ 'value' => 'testval' ] ),
694  'Checkbox wrapper with a value override.'
695  );
696  }
697 
698  public function testWrapperRadio() {
699  $this->assertEquals(
700  '<input type="radio" value="1" name="testname"/>',
701  Html::radio( 'testname' ),
702  'Radio wrapper unchecked.'
703  );
704  $this->assertEquals(
705  '<input checked="" type="radio" value="1" name="testname"/>',
706  Html::radio( 'testname', true ),
707  'Radio wrapper checked.'
708  );
709  $this->assertEquals(
710  '<input type="radio" value="testval" name="testname"/>',
711  Html::radio( 'testname', false, [ 'value' => 'testval' ] ),
712  'Radio wrapper with a value override.'
713  );
714  }
715 
716  public function testWrapperLabel() {
717  $this->assertEquals(
718  '<label for="testid">testlabel</label>',
719  Html::label( 'testlabel', 'testid' ),
720  'Label wrapper'
721  );
722  }
723 
724  public static function provideSrcSetImages() {
725  return [
726  [ [], '', 'when there are no images, return empty string' ],
727  [
728  [ '1x' => '1x.png', '1.5x' => '1_5x.png', '2x' => '2x.png' ],
729  '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
730  'pixel depth keys may include a trailing "x"'
731  ],
732  [
733  [ '1' => '1x.png', '1.5' => '1_5x.png', '2' => '2x.png' ],
734  '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
735  'pixel depth keys may omit a trailing "x"'
736  ],
737  [
738  [ '1' => 'small.png', '1.5' => 'large.png', '2' => 'large.png' ],
739  'small.png 1x, large.png 1.5x',
740  'omit larger duplicates'
741  ],
742  [
743  [ '1' => 'small.png', '2' => 'large.png', '1.5' => 'large.png' ],
744  'small.png 1x, large.png 1.5x',
745  'omit larger duplicates in irregular order'
746  ],
747  ];
748  }
749 
754  public function testSrcSet( $images, $expected, $message ) {
755  $this->assertEquals( Html::srcSet( $images ), $expected, $message );
756  }
757 }
758 
760  function __toString() {
761  return 'stringValue';
762  }
763 }
testExpandAttributes_ArrayOnNonListValueAttribute_ThrowsException()
Html::expandAttributes MWException
Definition: HtmlTest.php:294
testWrapperCheck()
Definition: HtmlTest.php:680
testHtmlElementAcceptsNewHtml5TypesInHtml5Mode($HTML5InputType)
provideHtml5InputTypes Html::element
Definition: HtmlTest.php:440
testCanDisableANamespaces()
Definition: HtmlTest.php:409
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
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:1936
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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:452
testElementBasics()
Html::element.
Definition: HtmlTest.php:45
testXmlMimeType($mimetype, $isXmlMimeType)
dataXmlMimeType Html::isXmlMimeType
Definition: HtmlTest.php:87
page as well
testExpandAttributesVariousExpansions()
Test for Html::expandAttributes() Please note it output a string prefixed with a space! Html::expand...
Definition: HtmlTest.php:171
static radio($name, $checked=false, array $attribs=[])
Convenience function to produce a radio button (input element with type=radio)
Definition: Html.php:719
testCanFilterOutNamespaces()
Definition: HtmlTest.php:387
tests for includes/Html.php
Definition: HtmlTest.php:4
testFormValidationBlacklist()
Html::expandAttributes
Definition: HtmlTest.php:641
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:1936
testExpandAttributesForNumbers()
Html::expandAttributes
Definition: HtmlTest.php:142
static check($name, $checked=false, array $attribs=[])
Convenience function to produce a checkbox (input element with type=checkbox)
Definition: Html.php:696
testExpandAttributesSpaceSeparatedAttributesWithBoolean()
Test feature added by r96188, let pass attributes values as a PHP array.
Definition: HtmlTest.php:254
testExpandAttributesListValueAttributes()
Html::expandAttributes has special features for HTML attributes that use space separated lists and al...
Definition: HtmlTest.php:202
testWrapperRadio()
Definition: HtmlTest.php:698
testExpandAttributesForObjects()
Html::expandAttributes
Definition: HtmlTest.php:158
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:1936
static expandAttributes(array $attribs)
Given an associative array of element attributes, generate a string to stick after the element name i...
Definition: Html.php:470
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:115
testDropDefaults($expected, $element, $attribs, $message= '')
Test out Html::element drops or enforces default value Html::dropDefaults provideElementsWithAttrib...
Definition: HtmlTest.php:481
static srcSet(array $urls)
Generate a srcset attribute value.
Definition: Html.php:1023
dataXmlMimeType()
Definition: HtmlTest.php:65
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:308
static input($name, $value= '', $type= 'text', array $attribs=[])
Convenience function to produce an "" element.
Definition: Html.php:675
testWrapperLabel()
Definition: HtmlTest.php:716
static isXmlMimeType($mimetype)
Determines if the given MIME type is xml.
Definition: Html.php:958
static provideSrcSetImages()
Definition: HtmlTest.php:724
testExpandAttributesSkipsNullAndFalse()
Html::expandAttributes
Definition: HtmlTest.php:94
testValueIsAuthoritativeInSpaceSeparatedAttributesArrays()
How do we handle duplicate keys in HTML attributes expansion? We could pass a "class" the values: 'GR...
Definition: HtmlTest.php:279
setUp()
Definition: HtmlTest.php:6
static factory($code)
Get a cached or new language object for a given language code.
Definition: Language.php:181
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:667
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:229
testSrcSet($images, $expected, $message)
provideSrcSetImages Html::srcSet
Definition: HtmlTest.php:754
static provideElementsWithAttributesHavingDefaultValues()
Definition: HtmlTest.php:485
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:2491
static label($label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
Definition: Html.php:742
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:846