File: HTMLButtonFieldTest.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (189 lines) | stat: -rw-r--r-- 8,019 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
namespace MediaWiki\Tests\Integration\HTMLForm\Field;

use MediaWiki\HTMLForm\Field\HTMLButtonField;
use MediaWiki\Tests\Integration\HTMLForm\HTMLFormFieldTestCase;

/**
 * @covers MediaWiki\HTMLForm\Field\HTMLButtonField
 */
class HTMLButtonFieldTest extends HTMLFormFieldTestCase {
	/** @inheritDoc */
	protected $className = HTMLButtonField::class;

	public static function provideInputHtml() {
		yield 'Basic button' => [
			[
				'buttonlabel' => 'Click me',
			],
			'',
			'<button class="mw-htmlform-submit" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Button with CSS class' => [
			[
				'buttonlabel' => 'Click me',
				'cssclass' => 'my-button',
			],
			'',
			'<button class="mw-htmlform-submit my-button" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Primary progressive button' => [
			[
				'buttonlabel' => 'Click me',
				'flags' => [ 'primary', 'progressive' ]
			],
			'',
			'<button class="mw-htmlform-submit mw-htmlform-primary mw-htmlform-progressive" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Destructive button' => [
			[
				'buttonlabel' => 'Click me',
				'flags' => [ 'destructive' ]
			],
			'',
			'<button class="mw-htmlform-submit mw-htmlform-destructive" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Quiet button with CSS class' => [
			[
				'buttonlabel' => 'Click me',
				'cssclass' => 'my-button',
				'flags' => [ 'quiet' ]
			],
			'',
			'<button class="mw-htmlform-submit my-button mw-htmlform-quiet" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Disabled button' => [
			[
				'buttonlabel' => 'Click me',
				'disabled' => true
			],
			'',
			'<button class="mw-htmlform-submit" id="mw-input-testfield" type="button" name="testfield" disabled="">Click me</button>'
		];
	}

	public static function provideInputCodex() {
		yield 'Basic button' => [
			[
				'buttonlabel' => 'Click me',
			],
			'',
			false,
			'<button class="mw-htmlform-submit cdx-button" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Button with CSS class' => [
			[
				'buttonlabel' => 'Click me',
				'cssclass' => 'my-button',
			],
			'',
			false,
			'<button class="mw-htmlform-submit cdx-button my-button" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Primary progressive button' => [
			[
				'buttonlabel' => 'Click me',
				'flags' => [ 'primary', 'progressive' ]
			],
			'',
			false,
			'<button class="mw-htmlform-submit cdx-button cdx-button--weight-primary cdx-button--action-progressive" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Destructive button' => [
			[
				'buttonlabel' => 'Click me',
				'flags' => [ 'destructive' ]
			],
			'',
			false,
			'<button class="mw-htmlform-submit cdx-button cdx-button--action-destructive" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Quiet button with CSS class' => [
			[
				'buttonlabel' => 'Click me',
				'cssclass' => 'my-button',
				'flags' => [ 'quiet' ]
			],
			'',
			false,
			'<button class="mw-htmlform-submit cdx-button my-button cdx-button--weight-quiet" id="mw-input-testfield" type="button" name="testfield">Click me</button>'
		];

		yield 'Disabled button' => [
			[
				'buttonlabel' => 'Click me',
				'disabled' => true
			],
			'',
			false,
			'<button class="mw-htmlform-submit cdx-button" id="mw-input-testfield" type="button" name="testfield" disabled="">Click me</button>'
		];
	}

	public static function provideInputOOUI() {
		yield 'Basic button' => [
			[
				'buttonlabel' => 'Click me',
			],
			'',
			"<span id='mw-input-testfield' class='mw-htmlform-submit  oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonInputWidget'><button type='button' tabindex='0' name='testfield' value='' class='oo-ui-inputWidget-input oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-iconElement-noIcon'></span><span class='oo-ui-labelElement-label'>Click me</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></button></span>"
		];

		yield 'Button with CSS class' => [
			[
				'buttonlabel' => 'Click me',
				'cssclass' => 'my-button',
			],
			'',
			"<span id='mw-input-testfield' class='mw-htmlform-submit my-button oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonInputWidget'><button type='button' tabindex='0' name='testfield' value='' class='oo-ui-inputWidget-input oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-iconElement-noIcon'></span><span class='oo-ui-labelElement-label'>Click me</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></button></span>"
		];

		yield 'Primary progressive button' => [
			[
				'buttonlabel' => 'Click me',
				'flags' => [ 'primary', 'progressive' ]
			],
			'',
			"<span id='mw-input-testfield' class='mw-htmlform-submit  oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-primary oo-ui-flaggedElement-progressive oo-ui-buttonInputWidget'><button type='button' tabindex='0' name='testfield' value='' class='oo-ui-inputWidget-input oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-iconElement-noIcon'></span><span class='oo-ui-labelElement-label'>Click me</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></button></span>"

		];

		yield 'Destructive button' => [
			[
				'buttonlabel' => 'Click me',
				'flags' => [ 'destructive' ]
			],
			'',
			"<span id='mw-input-testfield' class='mw-htmlform-submit  oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-destructive oo-ui-buttonInputWidget'><button type='button' tabindex='0' name='testfield' value='' class='oo-ui-inputWidget-input oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-iconElement-noIcon'></span><span class='oo-ui-labelElement-label'>Click me</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></button></span>"
		];

		yield 'Quiet button with CSS class' => [
			[
				'buttonlabel' => 'Click me',
				'cssclass' => 'my-button',
				'flags' => [ 'quiet' ]
			],
			'',
			"<span id='mw-input-testfield' class='mw-htmlform-submit my-button oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-quiet oo-ui-buttonInputWidget'><button type='button' tabindex='0' name='testfield' value='' class='oo-ui-inputWidget-input oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-iconElement-noIcon'></span><span class='oo-ui-labelElement-label'>Click me</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></button></span>"

		];

		yield 'Disabled button' => [
			[
				'buttonlabel' => 'Click me',
				'disabled' => true
			],
			'',
			"<span id='mw-input-testfield' aria-disabled='true' class='mw-htmlform-submit  oo-ui-widget oo-ui-widget-disabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonInputWidget'><button type='button' tabindex='-1' aria-disabled='true' name='testfield' disabled='disabled' value='' class='oo-ui-inputWidget-input oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-iconElement-noIcon'></span><span class='oo-ui-labelElement-label'>Click me</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></button></span>"
		];
	}
}