Debian Codegraph @

tests/phpunit/integration/includes/HTMLForm/Field/HTMLCheckFieldTest.php

raw symbols SCIP
1 <?php
2 namespace MediaWiki\Tests\Integration\HTMLForm\Field;
3
4 use MediaWiki\HTMLForm\Field\HTMLCheckField;
5 use MediaWiki\Tests\Integration\HTMLForm\HTMLFormFieldTestCase;
6
7 /**
8 * @covers MediaWiki\HTMLForm\Field\HTMLCheckField
9 */
10 class HTMLCheckFieldTest extends HTMLFormFieldTestCase {
11 /** @inheritDoc */
12 protected $className = HTMLCheckField::class;
13
14 public static function provideInputCodex() {
15 yield 'Basic checkbox' => [
16 [
17 'label' => 'Check me',
18 ],
19 false,
20 false,
21 <<<HTML
22 <div class="cdx-checkbox">
23 <input name="testfield" type="checkbox" value="1" id="mw-input-testfield" class=" cdx-checkbox__input" />
24 <span class="cdx-checkbox__icon">\u{00A0}</span>
25 <label for="mw-input-testfield" class="cdx-checkbox__label">Check me</label>
26 </div>
27 HTML
28 ];
29
30 yield 'Checked checkbox with CSS class' => [
31 [
32 'label' => 'Check me',
33 'cssclass' => 'my-checkbox'
34 ],
35 '1',
36 false,
37 <<<HTML
38 <div class="cdx-checkbox">
39 <input name="testfield" type="checkbox" value="1" checked="checked" id="mw-input-testfield" class="my-checkbox cdx-checkbox__input" />
40 <span class="cdx-checkbox__icon">\u{00A0}</span>
41 <label for="mw-input-testfield" class="cdx-checkbox__label">Check me</label>
42 </div>
43 HTML
44 ];
45
46 yield 'Inverted checkbox' => [
47 [
48 'label' => 'Check me',
49 'invert' => true
50 ],
51 false,
52 false,
53 <<<HTML
54 <div class="cdx-checkbox">
55 <input name="testfield" type="checkbox" value="1" checked="checked" id="mw-input-testfield" class=" cdx-checkbox__input" />
56 <span class="cdx-checkbox__icon">\u{00A0}</span>
57 <label for="mw-input-testfield" class="cdx-checkbox__label">Check me</label>
58 </div>
59 HTML
60 ];
61
62 yield 'Disabled checkbox with error state' => [
63 [
64 'label' => 'Check me',
65 'disabled' => true,
66 ],
67 false,
68 true,
69 <<<HTML
70 <div class="cdx-checkbox cdx-checkbox--status-error">
71 <input name="testfield" type="checkbox" value="1" id="mw-input-testfield" disabled="" class=" cdx-checkbox__input" />
72 <span class="cdx-checkbox__icon">\u{00A0}</span>
73 <label for="mw-input-testfield" class="cdx-checkbox__label">Check me</label>
74 </div>
75 HTML
76 ];
77
78 yield 'Checkbox with tooltip and accesskey' => [
79 [
80 'label' => 'Watch',
81 'tooltip' => 'watch'
82 ],
83 false,
84 false,
85 <<<HTML
86 <div class="cdx-checkbox" title="Add this page to your watchlist [w]">
87 <input name="testfield" type="checkbox" value="1" title="Add this page to your watchlist [w]" accesskey="w" id="mw-input-testfield" class=" cdx-checkbox__input" />
88 <span class="cdx-checkbox__icon">\u{00A0}</span>
89 <label for="mw-input-testfield" class="cdx-checkbox__label">Watch</label>
90 </div>
91 HTML
92 ];
93 }
94 }