MediaWiki  master
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[] = [ '<command/>',
518  'command', [ 'type' => 'command' ]
519  ];
520 
521  $cases[] = [ '<form></form>',
522  'form', [ 'action' => 'GET' ]
523  ];
524  $cases[] = [ '<form></form>',
525  'form', [ 'autocomplete' => 'on' ]
526  ];
527  $cases[] = [ '<form></form>',
528  'form', [ 'enctype' => 'application/x-www-form-urlencoded' ]
529  ];
530 
531  $cases[] = [ '<input/>',
532  'input', [ 'formaction' => 'GET' ]
533  ];
534  $cases[] = [ '<input/>',
535  'input', [ 'type' => 'text' ]
536  ];
537 
538  $cases[] = [ '<keygen/>',
539  'keygen', [ 'keytype' => 'rsa' ]
540  ];
541 
542  $cases[] = [ '<link/>',
543  'link', [ 'media' => 'all' ]
544  ];
545 
546  $cases[] = [ '<menu></menu>',
547  'menu', [ 'type' => 'list' ]
548  ];
549 
550  $cases[] = [ '<script></script>',
551  'script', [ 'type' => 'text/javascript' ]
552  ];
553 
554  $cases[] = [ '<style></style>',
555  'style', [ 'media' => 'all' ]
556  ];
557  $cases[] = [ '<style></style>',
558  'style', [ 'type' => 'text/css' ]
559  ];
560 
561  $cases[] = [ '<textarea></textarea>',
562  'textarea', [ 'wrap' => 'soft' ]
563  ];
564 
565  # ## SPECIFIC CASES
566 
567  # <link type="text/css">
568  $cases[] = [ '<link/>',
569  'link', [ 'type' => 'text/css' ]
570  ];
571 
572  # <input> specific handling
573  $cases[] = [ '<input type="checkbox"/>',
574  'input', [ 'type' => 'checkbox', 'value' => 'on' ],
575  'Default value "on" is stripped of checkboxes',
576  ];
577  $cases[] = [ '<input type="radio"/>',
578  'input', [ 'type' => 'radio', 'value' => 'on' ],
579  'Default value "on" is stripped of radio buttons',
580  ];
581  $cases[] = [ '<input type="submit" value="Submit"/>',
582  'input', [ 'type' => 'submit', 'value' => 'Submit' ],
583  'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
584  ];
585  $cases[] = [ '<input type="color"/>',
586  'input', [ 'type' => 'color', 'value' => '' ],
587  ];
588  $cases[] = [ '<input type="range"/>',
589  'input', [ 'type' => 'range', 'value' => '' ],
590  ];
591 
592  # <button> specific handling
593  # see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
594  $cases[] = [ '<button type="submit"></button>',
595  'button', [ 'type' => 'submit' ],
596  'According to standard the default type is "submit". '
597  . 'Depending on compatibility mode IE might use "button", instead.',
598  ];
599 
600  # <select> specific handling
601  $cases[] = [ '<select multiple=""></select>',
602  'select', [ 'size' => '4', 'multiple' => true ],
603  ];
604  # .. with numeric value
605  $cases[] = [ '<select multiple=""></select>',
606  'select', [ 'size' => 4, 'multiple' => true ],
607  ];
608  $cases[] = [ '<select></select>',
609  'select', [ 'size' => '1', 'multiple' => false ],
610  ];
611  # .. with numeric value
612  $cases[] = [ '<select></select>',
613  'select', [ 'size' => 1, 'multiple' => false ],
614  ];
615 
616  # Passing an array as value
617  $cases[] = [ '<a class="css-class-one css-class-two"></a>',
618  'a', [ 'class' => [ 'css-class-one', 'css-class-two' ] ],
619  "dropDefaults accepts values given as an array"
620  ];
621 
622  # FIXME: doDropDefault should remove defaults given in an array
623  # Expected should be '<a></a>'
624  $cases[] = [ '<a class=""></a>',
625  'a', [ 'class' => [ '', '' ] ],
626  "dropDefaults accepts values given as an array"
627  ];
628 
629  # Craft the Html elements
630  $ret = [];
631  foreach ( $cases as $case ) {
632  $ret[] = [
633  $case[0],
634  $case[1], $case[2],
635  isset( $case[3] ) ? $case[3] : ''
636  ];
637  }
638 
639  return $ret;
640  }
641 
645  public function testFormValidationBlacklist() {
646  $this->assertEmpty(
648  'min' => 1,
649  'max' => 100,
650  'pattern' => 'abc',
651  'required' => true,
652  'step' => 2
653  ] ),
654  'Blacklist form validation attributes.'
655  );
656  $this->assertEquals(
657  ' step="any"',
659  [
660  'min' => 1,
661  'max' => 100,
662  'pattern' => 'abc',
663  'required' => true,
664  'step' => 'any'
665  ],
666  'Allow special case "step=any".'
667  )
668  );
669  }
670 
671  public function testWrapperInput() {
672  $this->assertEquals(
673  '<input type="radio" value="testval" name="testname"/>',
674  Html::input( 'testname', 'testval', 'radio' ),
675  'Input wrapper with type and value.'
676  );
677  $this->assertEquals(
678  '<input name="testname"/>',
679  Html::input( 'testname' ),
680  'Input wrapper with all default values.'
681  );
682  }
683 
684  public function testWrapperCheck() {
685  $this->assertEquals(
686  '<input type="checkbox" value="1" name="testname"/>',
687  Html::check( 'testname' ),
688  'Checkbox wrapper unchecked.'
689  );
690  $this->assertEquals(
691  '<input checked="" type="checkbox" value="1" name="testname"/>',
692  Html::check( 'testname', true ),
693  'Checkbox wrapper checked.'
694  );
695  $this->assertEquals(
696  '<input type="checkbox" value="testval" name="testname"/>',
697  Html::check( 'testname', false, [ 'value' => 'testval' ] ),
698  'Checkbox wrapper with a value override.'
699  );
700  }
701 
702  public function testWrapperRadio() {
703  $this->assertEquals(
704  '<input type="radio" value="1" name="testname"/>',
705  Html::radio( 'testname' ),
706  'Radio wrapper unchecked.'
707  );
708  $this->assertEquals(
709  '<input checked="" type="radio" value="1" name="testname"/>',
710  Html::radio( 'testname', true ),
711  'Radio wrapper checked.'
712  );
713  $this->assertEquals(
714  '<input type="radio" value="testval" name="testname"/>',
715  Html::radio( 'testname', false, [ 'value' => 'testval' ] ),
716  'Radio wrapper with a value override.'
717  );
718  }
719 
720  public function testWrapperLabel() {
721  $this->assertEquals(
722  '<label for="testid">testlabel</label>',
723  Html::label( 'testlabel', 'testid' ),
724  'Label wrapper'
725  );
726  }
727 
728  public static function provideSrcSetImages() {
729  return [
730  [ [], '', 'when there are no images, return empty string' ],
731  [
732  [ '1x' => '1x.png', '1.5x' => '1_5x.png', '2x' => '2x.png' ],
733  '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
734  'pixel depth keys may include a trailing "x"'
735  ],
736  [
737  [ '1' => '1x.png', '1.5' => '1_5x.png', '2' => '2x.png' ],
738  '1x.png 1x, 1_5x.png 1.5x, 2x.png 2x',
739  'pixel depth keys may omit a trailing "x"'
740  ],
741  [
742  [ '1' => 'small.png', '1.5' => 'large.png', '2' => 'large.png' ],
743  'small.png 1x, large.png 1.5x',
744  'omit larger duplicates'
745  ],
746  [
747  [ '1' => 'small.png', '2' => 'large.png', '1.5' => 'large.png' ],
748  'small.png 1x, large.png 1.5x',
749  'omit larger duplicates in irregular order'
750  ],
751  ];
752  }
753 
758  public function testSrcSet( $images, $expected, $message ) {
759  $this->assertEquals( Html::srcSet( $images ), $expected, $message );
760  }
761 }
762 
764  function __toString() {
765  return 'stringValue';
766  }
767 }
testExpandAttributes_ArrayOnNonListValueAttribute_ThrowsException()
Html::expandAttributes MWException
Definition: HtmlTest.php:294
testWrapperCheck()
Definition: HtmlTest.php:684
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
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:710
testCanFilterOutNamespaces()
Definition: HtmlTest.php:387
tests for includes/Html.php
Definition: HtmlTest.php:4
testFormValidationBlacklist()
Html::expandAttributes
Definition: HtmlTest.php:645
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:1816
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:687
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:702
testExpandAttributesForObjects()
Html::expandAttributes
Definition: HtmlTest.php:158
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
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:1816
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:1014
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 "<input>" element.
Definition: Html.php:666
testWrapperLabel()
Definition: HtmlTest.php:720
static isXmlMimeType($mimetype)
Determines if the given MIME type is xml.
Definition: Html.php:949
static provideSrcSetImages()
Definition: HtmlTest.php:728
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: '...
Definition: HtmlTest.php:279
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:1816
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:671
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:758
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:2376
static label($label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
Definition: Html.php:733
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:837