1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* Webform module tests.
|
5 |
|
|
*/
|
6 |
|
|
class WebformTestCase extends DrupalWebTestCase {
|
7 |
|
|
private $_webform_node;
|
8 |
|
|
private $_webform_components;
|
9 |
|
|
public $webform_users;
|
10 |
|
|
|
11 |
|
|
/**
|
12 |
8c72e82a
|
Assos Assos
|
* {@inheritdoc}
|
13 |
85ad3d82
|
Assos Assos
|
*/
|
14 |
feca1e4a
|
Assos Assos
|
public function setUp($added_modules = array()) {
|
15 |
a45e4bc1
|
Assos Assos
|
// Enable Webform and Token module if available.
|
16 |
|
|
if (module_exists('token')) {
|
17 |
|
|
$modules = array('webform', 'token');
|
18 |
|
|
}
|
19 |
|
|
else {
|
20 |
|
|
$modules = array('webform');
|
21 |
|
|
}
|
22 |
|
|
parent::setUp(array_merge($modules, $added_modules));
|
23 |
85ad3d82
|
Assos Assos
|
|
24 |
a45e4bc1
|
Assos Assos
|
// Create a profile field to test [user:?] tokens.
|
25 |
|
|
$field = array(
|
26 |
|
|
'field_name' => 'gender',
|
27 |
|
|
'type' => 'text',
|
28 |
|
|
'cardinality' => 1,
|
29 |
|
|
);
|
30 |
|
|
$instance = array(
|
31 |
|
|
'field_name' => 'gender',
|
32 |
|
|
'entity_type' => 'user',
|
33 |
|
|
'bundle' => 'user',
|
34 |
|
|
'label' => 'Gender',
|
35 |
|
|
'widget' => array(
|
36 |
|
|
'type' => 'text_textfield',
|
37 |
|
|
'label' => 'Gender',
|
38 |
|
|
),
|
39 |
|
|
);
|
40 |
|
|
field_create_field($field);
|
41 |
|
|
field_create_instance($instance);
|
42 |
85ad3d82
|
Assos Assos
|
|
43 |
|
|
// Create a normal user that can view their own submissions.
|
44 |
|
|
$permissions['userAccess'] = array(
|
45 |
|
|
'access content',
|
46 |
|
|
'access own webform submissions',
|
47 |
|
|
);
|
48 |
|
|
|
49 |
|
|
// Create a normal user than can edit their own submissions.
|
50 |
|
|
$permissions['userEdit'] = array(
|
51 |
|
|
'access content',
|
52 |
|
|
'edit own webform submissions',
|
53 |
|
|
);
|
54 |
|
|
|
55 |
|
|
// Create a webform editor to test creating and editing own content.
|
56 |
|
|
$permissions['editor'] = array(
|
57 |
|
|
'access content',
|
58 |
|
|
'create webform content',
|
59 |
|
|
'edit own webform content',
|
60 |
|
|
'access all webform results',
|
61 |
|
|
);
|
62 |
|
|
|
63 |
|
|
// Create a webform admin that will do all node creation.
|
64 |
|
|
$permissions['admin'] = array(
|
65 |
|
|
'access content',
|
66 |
|
|
'administer nodes',
|
67 |
|
|
'create webform content',
|
68 |
|
|
'edit any webform content',
|
69 |
|
|
'access all webform results',
|
70 |
|
|
'edit all webform submissions',
|
71 |
|
|
'delete all webform submissions',
|
72 |
|
|
);
|
73 |
|
|
|
74 |
|
|
foreach ($permissions as $user_key => $role_permissions) {
|
75 |
|
|
$this->webform_users[$user_key] = $this->drupalCreateUser($role_permissions);
|
76 |
a45e4bc1
|
Assos Assos
|
$this->webform_users[$user_key]->gender = array(LANGUAGE_NONE => array(array('value' => 'Female')));
|
77 |
|
|
user_save($this->webform_users[$user_key]);
|
78 |
85ad3d82
|
Assos Assos
|
}
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
/**
|
82 |
8c72e82a
|
Assos Assos
|
* {@inheritdoc}
|
83 |
85ad3d82
|
Assos Assos
|
*/
|
84 |
feca1e4a
|
Assos Assos
|
public function tearDown() {
|
85 |
85ad3d82
|
Assos Assos
|
// Delete the webform admin and any created nodes.
|
86 |
|
|
foreach ($this->webform_users as $account) {
|
87 |
|
|
$uid = $account->uid;
|
88 |
|
|
$result = db_select('node')
|
89 |
|
|
->fields('node')
|
90 |
|
|
->condition('uid', $uid)
|
91 |
|
|
->execute();
|
92 |
|
|
foreach ($result as $node) {
|
93 |
|
|
node_delete($node->nid);
|
94 |
|
|
}
|
95 |
|
|
user_cancel(array(), $uid, 'user_cancel_delete');
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
parent::tearDown();
|
99 |
|
|
}
|
100 |
|
|
|
101 |
feca1e4a
|
Assos Assos
|
/**
|
102 |
|
|
*
|
103 |
|
|
*/
|
104 |
|
|
public function webformReset() {
|
105 |
85ad3d82
|
Assos Assos
|
$this->_webform_node = NULL;
|
106 |
|
|
$this->_webform_components = NULL;
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
/**
|
110 |
|
|
* Provide a list of components to test throughout the suite.
|
111 |
|
|
*
|
112 |
|
|
* Each component provides:
|
113 |
|
|
* - A default configuration for the component.
|
114 |
|
|
* - Values to try setting via POST
|
115 |
|
|
* - Values that should match the database storage when set via POST
|
116 |
|
|
* - Values that should match the database storage when using the default values.
|
117 |
|
|
*
|
118 |
|
|
* @return array
|
119 |
|
|
* An array of each component settings.
|
120 |
|
|
*/
|
121 |
feca1e4a
|
Assos Assos
|
public function webformComponents() {
|
122 |
85ad3d82
|
Assos Assos
|
if (isset($this->_webform_components)) {
|
123 |
|
|
return $this->_webform_components;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
$this->_webform_components = array(
|
127 |
|
|
// Test date components.
|
128 |
|
|
'date' => array(
|
129 |
|
|
'component' => array(
|
130 |
|
|
'form_key' => 'date',
|
131 |
|
|
'name' => 'Date',
|
132 |
|
|
'type' => 'date',
|
133 |
|
|
'value' => '19 Nov 1978',
|
134 |
|
|
'extra' => array(
|
135 |
|
|
'timezone' => 'site',
|
136 |
|
|
'start_date' => '-100 years',
|
137 |
|
|
'end_date' => '+2 years',
|
138 |
|
|
),
|
139 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
140 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
141 |
|
|
'weight' => '-15',
|
142 |
|
|
),
|
143 |
|
|
'sample values' => array('day' => '30', 'month' => '9', 'year' => '1982'),
|
144 |
|
|
'database values' => array('1982-09-30'),
|
145 |
|
|
'database default values' => array('1978-11-19'),
|
146 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
147 |
|
|
'match conditional values' => array(
|
148 |
|
|
'equal' => '1982/9/30',
|
149 |
|
|
'before' => '1982/10/1',
|
150 |
|
|
'before_equal' => '1982/9/30',
|
151 |
|
|
'after' => '1982/9/29',
|
152 |
|
|
'after_equal' => '1982/9/29',
|
153 |
|
|
),
|
154 |
|
|
'mismatch conditional values' => array(
|
155 |
|
|
'equal' => '1981/9/30',
|
156 |
|
|
'before' => '1982/9/30',
|
157 |
|
|
'before_equal' => '1982/9/29',
|
158 |
|
|
'after' => '1982/9/30',
|
159 |
|
|
'after_equal' => '1982/10/1',
|
160 |
|
|
),
|
161 |
85ad3d82
|
Assos Assos
|
),
|
162 |
|
|
|
163 |
|
|
// Test grid components.
|
164 |
|
|
'grid' => array(
|
165 |
|
|
'component' => array(
|
166 |
|
|
'form_key' => 'grid',
|
167 |
|
|
'name' => 'Grid',
|
168 |
|
|
'type' => 'grid',
|
169 |
|
|
'value' => '',
|
170 |
|
|
'extra' => array(
|
171 |
feca1e4a
|
Assos Assos
|
// Left side.
|
172 |
|
|
'questions' => "0|Ålphå\n1|ıé†å\n2|Î鬆å",
|
173 |
|
|
// Top.
|
174 |
|
|
'options' => "0|øne\n1|twö\n2|ǼBƇ\n3|€Euro",
|
175 |
85ad3d82
|
Assos Assos
|
),
|
176 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
177 |
85ad3d82
|
Assos Assos
|
'pid' => '2',
|
178 |
|
|
'weight' => '-19',
|
179 |
|
|
),
|
180 |
|
|
'sample values' => array('0' => '0', '1' => '1', '2' => '2'),
|
181 |
|
|
'database values' => array('0' => '0', '1' => '1', '2' => '2'),
|
182 |
|
|
'database default values' => array('', '', ''),
|
183 |
|
|
),
|
184 |
|
|
'grid_keyed' => array(
|
185 |
|
|
'component' => array(
|
186 |
|
|
'form_key' => 'grid_keyed',
|
187 |
|
|
'name' => 'Grid Keyed',
|
188 |
|
|
'type' => 'grid',
|
189 |
|
|
'value' => '',
|
190 |
|
|
'extra' => array(
|
191 |
feca1e4a
|
Assos Assos
|
// Left side.
|
192 |
|
|
'questions' => "one|What's your option?\ntwo|Agåin?\nthree|One more time!",
|
193 |
|
|
// Top.
|
194 |
|
|
'options' => "one|Option one\ntwo|Option 2\nthree| Three is me",
|
195 |
85ad3d82
|
Assos Assos
|
),
|
196 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
197 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
198 |
|
|
'weight' => '-15',
|
199 |
|
|
),
|
200 |
|
|
'sample values' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
|
201 |
|
|
'database values' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
|
202 |
|
|
'database default values' => array('one' => '', 'two' => '', 'three' => ''),
|
203 |
|
|
),
|
204 |
|
|
|
205 |
|
|
// Test select components.
|
206 |
|
|
'checkboxes' => array(
|
207 |
|
|
'component' => array(
|
208 |
|
|
'form_key' => 'checkboxes',
|
209 |
|
|
'name' => 'Checkboxes',
|
210 |
|
|
'type' => 'select',
|
211 |
|
|
'value' => 'two',
|
212 |
|
|
'extra' => array(
|
213 |
|
|
'items' => "one|one\ntwo|two\nthree|three",
|
214 |
|
|
'multiple' => 1,
|
215 |
|
|
),
|
216 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
217 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
218 |
|
|
'weight' => '-15',
|
219 |
|
|
),
|
220 |
|
|
'sample values' => array('one' => TRUE, 'two' => FALSE, 'three' => TRUE),
|
221 |
|
|
'database values' => array('one', 'three'),
|
222 |
|
|
'database default values' => array('two'),
|
223 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
224 |
|
|
'match conditional values' => array(
|
225 |
feca1e4a
|
Assos Assos
|
// ANDed together match.
|
226 |
|
|
'equal' => array('one', 'three'),
|
227 |
a45e4bc1
|
Assos Assos
|
'not_equal' => array('two'),
|
228 |
|
|
),
|
229 |
|
|
'mismatch conditional values' => array(
|
230 |
|
|
'equal' => array('one', 'two'),
|
231 |
|
|
'not_equal' => array('two', 'three'),
|
232 |
|
|
),
|
233 |
85ad3d82
|
Assos Assos
|
),
|
234 |
|
|
'checkboxes_zero' => array(
|
235 |
|
|
'component' => array(
|
236 |
|
|
'form_key' => 'checkboxes_zero',
|
237 |
|
|
'name' => 'Checkboxes zero',
|
238 |
|
|
'type' => 'select',
|
239 |
|
|
'value' => '0',
|
240 |
|
|
'extra' => array(
|
241 |
|
|
'items' => "0|zero\n1|one\n2|two",
|
242 |
|
|
'multiple' => 1,
|
243 |
|
|
),
|
244 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
245 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
246 |
|
|
'weight' => '-9',
|
247 |
|
|
),
|
248 |
|
|
'sample values' => array('0' => TRUE),
|
249 |
|
|
'database values' => array('0'),
|
250 |
|
|
'database default values' => array('0'),
|
251 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
252 |
|
|
'match conditional values' => array(
|
253 |
|
|
'equal' => '0',
|
254 |
|
|
'not_equal' => '1',
|
255 |
|
|
),
|
256 |
|
|
'mismatch conditional values' => array(
|
257 |
|
|
'equal' => '1',
|
258 |
|
|
'not_equal' => '0',
|
259 |
|
|
),
|
260 |
85ad3d82
|
Assos Assos
|
),
|
261 |
|
|
'radios' => array(
|
262 |
|
|
'component' => array(
|
263 |
|
|
'form_key' => 'radios',
|
264 |
|
|
'name' => 'Radios',
|
265 |
|
|
'type' => 'select',
|
266 |
|
|
'value' => 'two',
|
267 |
|
|
'extra' => array(
|
268 |
|
|
'items' => "one|one\ntwo|two\nthree|three",
|
269 |
|
|
),
|
270 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
271 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
272 |
|
|
'weight' => '-9',
|
273 |
|
|
),
|
274 |
|
|
'sample values' => 'one',
|
275 |
|
|
'database values' => array('one'),
|
276 |
|
|
'database default values' => array('two'),
|
277 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
278 |
|
|
'match conditional values' => array(
|
279 |
|
|
'equal' => 'one',
|
280 |
|
|
'not_equal' => 'two',
|
281 |
|
|
),
|
282 |
|
|
'mismatch conditional values' => array(
|
283 |
|
|
'equal' => 'two',
|
284 |
|
|
'not_equal' => 'one',
|
285 |
|
|
),
|
286 |
85ad3d82
|
Assos Assos
|
),
|
287 |
|
|
'radios_zero' => array(
|
288 |
|
|
'component' => array(
|
289 |
|
|
'form_key' => 'radios_zero',
|
290 |
|
|
'name' => 'Radios zero',
|
291 |
|
|
'type' => 'select',
|
292 |
|
|
'value' => '0',
|
293 |
|
|
'extra' => array(
|
294 |
|
|
'items' => "0|zero\n1|one\n2|two",
|
295 |
|
|
),
|
296 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
297 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
298 |
|
|
'weight' => '-9',
|
299 |
|
|
),
|
300 |
|
|
'sample values' => '0',
|
301 |
|
|
'database values' => array('0'),
|
302 |
|
|
'database default values' => array('0'),
|
303 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
304 |
|
|
'match conditional values' => array(
|
305 |
|
|
'equal' => '0',
|
306 |
|
|
'not_equal' => '1',
|
307 |
|
|
),
|
308 |
|
|
'mismatch conditional values' => array(
|
309 |
|
|
'equal' => '1',
|
310 |
|
|
'not_equal' => '0',
|
311 |
|
|
),
|
312 |
|
|
),
|
313 |
|
|
'radios_relative' => array(
|
314 |
|
|
'component' => array(
|
315 |
|
|
'form_key' => 'radios_relative',
|
316 |
|
|
'name' => 'Radios relative',
|
317 |
|
|
'type' => 'select',
|
318 |
|
|
'value' => 'one',
|
319 |
|
|
'extra' => array(
|
320 |
|
|
'items' => "zero|Zero\none|One\ntwo|Two\nthree|Three\n",
|
321 |
|
|
),
|
322 |
|
|
'required' => '1',
|
323 |
|
|
'pid' => '0',
|
324 |
|
|
'weight' => '-9',
|
325 |
|
|
),
|
326 |
|
|
'sample values' => 'one',
|
327 |
|
|
'database values' => array('one'),
|
328 |
|
|
'database default values' => array('one'),
|
329 |
|
|
// Conditionals match against the 'sample values'.
|
330 |
|
|
'match conditional values' => array(
|
331 |
|
|
'equal' => 'one',
|
332 |
|
|
'not_equal' => 'zero',
|
333 |
|
|
'less_than' => 'two',
|
334 |
|
|
'less_than_equal' => 'one',
|
335 |
|
|
'greater_than' => 'zero',
|
336 |
|
|
'greater_than_equal' => 'zero',
|
337 |
|
|
),
|
338 |
|
|
'mismatch conditional values' => array(
|
339 |
|
|
'equal' => 'zero',
|
340 |
|
|
'not_equal' => 'one',
|
341 |
|
|
'less_than' => 'one',
|
342 |
|
|
'less_than_equal' => 'zero',
|
343 |
|
|
'greater_than' => 'two',
|
344 |
|
|
'greater_than_equal' => 'two',
|
345 |
|
|
),
|
346 |
85ad3d82
|
Assos Assos
|
),
|
347 |
|
|
'select' => array(
|
348 |
|
|
'component' => array(
|
349 |
|
|
'form_key' => 'select',
|
350 |
|
|
'name' => 'Select',
|
351 |
|
|
'type' => 'select',
|
352 |
|
|
'value' => 'one',
|
353 |
|
|
'extra' => array(
|
354 |
|
|
'description' => 'Description here',
|
355 |
|
|
'items' => "one|one\ntwo|two\nthree|three\nfour|four\nfive|five\nsix|six",
|
356 |
|
|
'aslist' => 1,
|
357 |
|
|
),
|
358 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
359 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
360 |
|
|
'weight' => '-15',
|
361 |
|
|
),
|
362 |
|
|
'sample values' => 'two',
|
363 |
|
|
'database values' => array('two'),
|
364 |
|
|
'database default values' => array('one'),
|
365 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
366 |
|
|
'match conditional values' => array(
|
367 |
|
|
'equal' => 'two',
|
368 |
|
|
'not_equal' => 'one',
|
369 |
|
|
),
|
370 |
|
|
'mismatch conditional values' => array(
|
371 |
|
|
'equal' => 'one',
|
372 |
|
|
'not_equal' => 'two',
|
373 |
|
|
),
|
374 |
85ad3d82
|
Assos Assos
|
),
|
375 |
|
|
'select_zero' => array(
|
376 |
|
|
'component' => array(
|
377 |
|
|
'form_key' => 'select_zero',
|
378 |
|
|
'name' => 'Select zero',
|
379 |
|
|
'type' => 'select',
|
380 |
|
|
'value' => '0',
|
381 |
|
|
'extra' => array(
|
382 |
|
|
'description' => 'Tests saving zero as a value.',
|
383 |
|
|
'items' => "0|zero\n1|one\n2|two",
|
384 |
|
|
'aslist' => 1,
|
385 |
|
|
),
|
386 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
387 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
388 |
|
|
'weight' => '-15',
|
389 |
|
|
),
|
390 |
|
|
'sample values' => '0',
|
391 |
|
|
'database values' => array('0'),
|
392 |
|
|
'database default values' => array('0'),
|
393 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
394 |
|
|
'match conditional values' => array(
|
395 |
|
|
'equal' => '0',
|
396 |
|
|
'not_equal' => '1',
|
397 |
|
|
),
|
398 |
|
|
'mismatch conditional values' => array(
|
399 |
|
|
'equal' => '1',
|
400 |
|
|
'not_equal' => '0',
|
401 |
|
|
),
|
402 |
85ad3d82
|
Assos Assos
|
),
|
403 |
|
|
'select_no_default' => array(
|
404 |
|
|
'component' => array(
|
405 |
|
|
'form_key' => 'select_no_default',
|
406 |
|
|
'name' => 'Select no default',
|
407 |
|
|
'type' => 'select',
|
408 |
|
|
'value' => '',
|
409 |
|
|
'extra' => array(
|
410 |
|
|
'description' => 'Description here',
|
411 |
|
|
'items' => "one|one\ntwo|two\nthree|three\nfour|four\nfive|five\nsix|six",
|
412 |
|
|
'aslist' => 1,
|
413 |
|
|
),
|
414 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
415 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
416 |
|
|
'weight' => '-15',
|
417 |
|
|
),
|
418 |
|
|
'sample values' => 'two',
|
419 |
|
|
'database values' => array('two'),
|
420 |
|
|
'database default values' => array(''),
|
421 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
422 |
|
|
'match conditional values' => array(
|
423 |
|
|
'equal' => 'two',
|
424 |
|
|
'not_equal' => '',
|
425 |
|
|
),
|
426 |
|
|
'mismatch conditional values' => array(
|
427 |
|
|
'equal' => '',
|
428 |
|
|
'not_equal' => 'two',
|
429 |
|
|
),
|
430 |
85ad3d82
|
Assos Assos
|
),
|
431 |
|
|
'select_no_default_zero' => array(
|
432 |
|
|
'component' => array(
|
433 |
|
|
'form_key' => 'select_no_default_zero',
|
434 |
|
|
'name' => 'Select no default zero',
|
435 |
|
|
'type' => 'select',
|
436 |
|
|
'value' => '',
|
437 |
|
|
'extra' => array(
|
438 |
|
|
'description' => 'Tests saving zero as a value.',
|
439 |
|
|
'items' => "0|zero\n1|one\n2|two",
|
440 |
|
|
'aslist' => 1,
|
441 |
|
|
),
|
442 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
443 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
444 |
|
|
'weight' => '-15',
|
445 |
|
|
),
|
446 |
|
|
'sample values' => '0',
|
447 |
|
|
'database values' => array('0'),
|
448 |
|
|
'database default values' => array(''),
|
449 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
450 |
|
|
'match conditional values' => array(
|
451 |
|
|
'equal' => '0',
|
452 |
|
|
'not_equal' => '',
|
453 |
|
|
),
|
454 |
|
|
'mismatch conditional values' => array(
|
455 |
|
|
'equal' => '',
|
456 |
|
|
'not_equal' => '0',
|
457 |
|
|
),
|
458 |
85ad3d82
|
Assos Assos
|
),
|
459 |
|
|
'select_optgroup' => array(
|
460 |
|
|
'component' => array(
|
461 |
|
|
'form_key' => 'select_optgroup',
|
462 |
|
|
'name' => 'Select Optgroup',
|
463 |
|
|
'type' => 'select',
|
464 |
|
|
'value' => 'option 1-2',
|
465 |
|
|
'extra' => array(
|
466 |
|
|
'description' => 'Tests saving zero as a value.',
|
467 |
|
|
'items' => "<Group 1>\noption 1-1|option 1-1\noption 1-2|option 1-2\noption 1-3|option 1-3\n<Group 2>\noption 2-1|option 2-1\noption 2-2|option 2-2\noption 2-3|option 2-3",
|
468 |
|
|
'aslist' => 1,
|
469 |
|
|
),
|
470 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
471 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
472 |
|
|
'weight' => '-15',
|
473 |
|
|
),
|
474 |
|
|
'sample values' => 'option 2-2',
|
475 |
|
|
'database values' => array('option 2-2'),
|
476 |
|
|
'database default values' => array('option 1-2'),
|
477 |
|
|
),
|
478 |
|
|
'select_email' => array(
|
479 |
|
|
'component' => array(
|
480 |
|
|
'form_key' => 'select_email',
|
481 |
|
|
'name' => 'Select e-mails',
|
482 |
|
|
'type' => 'select',
|
483 |
|
|
'value' => 'nate@localhost.localhost',
|
484 |
|
|
'extra' => array(
|
485 |
|
|
'items' => "nate@localhost.localhost|one\nadmin@localhost.localhost|two",
|
486 |
|
|
),
|
487 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
488 |
85ad3d82
|
Assos Assos
|
'pid' => '2',
|
489 |
|
|
'weight' => '-17',
|
490 |
|
|
),
|
491 |
|
|
'sample values' => 'admin@localhost.localhost',
|
492 |
|
|
'database values' => array('admin@localhost.localhost'),
|
493 |
|
|
'database default values' => array('nate@localhost.localhost'),
|
494 |
|
|
),
|
495 |
|
|
'select_multiple' => array(
|
496 |
|
|
'component' => array(
|
497 |
|
|
'form_key' => 'select_multiple',
|
498 |
|
|
'name' => 'Select Multiple',
|
499 |
|
|
'type' => 'select',
|
500 |
|
|
'value' => 'one,two',
|
501 |
|
|
'extra' => array(
|
502 |
|
|
'items' => "one|one\ntwo|two\nthree|three",
|
503 |
|
|
'multiple' => 1,
|
504 |
|
|
'aslist' => 1,
|
505 |
|
|
),
|
506 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
507 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
508 |
|
|
'weight' => '-10',
|
509 |
|
|
),
|
510 |
8c72e82a
|
Assos Assos
|
// @todo: I'd like to test a value, but SimpleTest can't set multiple values.
|
511 |
85ad3d82
|
Assos Assos
|
'sample values' => NULL,
|
512 |
|
|
'database values' => array('one', 'two'),
|
513 |
|
|
'database default values' => array('one', 'two'),
|
514 |
|
|
),
|
515 |
a45e4bc1
|
Assos Assos
|
'select_relative' => array(
|
516 |
|
|
'component' => array(
|
517 |
|
|
'form_key' => 'select_relative',
|
518 |
|
|
'name' => 'Select relative',
|
519 |
|
|
'type' => 'select',
|
520 |
|
|
'value' => 'one',
|
521 |
|
|
'extra' => array(
|
522 |
|
|
'items' => "zero|Zero\none|One\ntwo|Two\nthree|Three\n",
|
523 |
|
|
'aslist' => 1,
|
524 |
|
|
),
|
525 |
|
|
'required' => '1',
|
526 |
|
|
'pid' => '0',
|
527 |
|
|
'weight' => '-9',
|
528 |
|
|
),
|
529 |
|
|
'sample values' => 'one',
|
530 |
|
|
'database values' => array('one'),
|
531 |
|
|
'database default values' => array('one'),
|
532 |
|
|
// Conditionals match against the 'sample values'.
|
533 |
|
|
'match conditional values' => array(
|
534 |
|
|
'equal' => 'one',
|
535 |
|
|
'not_equal' => 'zero',
|
536 |
|
|
'less_than' => 'two',
|
537 |
|
|
'less_than_equal' => 'one',
|
538 |
|
|
'greater_than' => 'zero',
|
539 |
|
|
'greater_than_equal' => 'zero',
|
540 |
|
|
),
|
541 |
|
|
'mismatch conditional values' => array(
|
542 |
|
|
'equal' => 'zero',
|
543 |
|
|
'not_equal' => 'one',
|
544 |
|
|
'less_than' => 'one',
|
545 |
|
|
'less_than_equal' => 'zero',
|
546 |
|
|
'greater_than' => 'two',
|
547 |
|
|
'greater_than_equal' => 'two',
|
548 |
|
|
),
|
549 |
|
|
),
|
550 |
85ad3d82
|
Assos Assos
|
|
551 |
|
|
// Test date components.
|
552 |
|
|
'date_textfield' => array(
|
553 |
|
|
'component' => array(
|
554 |
|
|
'form_key' => 'date_textfield',
|
555 |
|
|
'name' => 'Date Textfield',
|
556 |
|
|
'type' => 'date',
|
557 |
|
|
'value' => 'Nov 19 1978',
|
558 |
|
|
'extra' => array(
|
559 |
|
|
'timezone' => 'site',
|
560 |
|
|
'start_date' => '-100 years',
|
561 |
|
|
'end_date' => '+2 years',
|
562 |
|
|
'year_textfield' => 1,
|
563 |
|
|
),
|
564 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
565 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
566 |
|
|
'weight' => '-7',
|
567 |
|
|
),
|
568 |
|
|
'sample values' => array('day' => '30', 'month' => '9', 'year' => '1982'),
|
569 |
|
|
'database values' => array('1982-09-30'),
|
570 |
|
|
'database default values' => array('1978-11-19'),
|
571 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
572 |
|
|
'match conditional values' => array(
|
573 |
|
|
'equal' => '1982/9/30',
|
574 |
|
|
'before' => '1982/10/1',
|
575 |
|
|
'before_equal' => '1982/9/30',
|
576 |
|
|
'after' => '1982/9/29',
|
577 |
|
|
'after_equal' => '1982/9/29',
|
578 |
|
|
),
|
579 |
|
|
'mismatch conditional values' => array(
|
580 |
|
|
'equal' => '1981/9/30',
|
581 |
|
|
'before' => '1982/9/30',
|
582 |
|
|
'before_equal' => '1982/9/29',
|
583 |
|
|
'after' => '1982/9/30',
|
584 |
|
|
'after_equal' => '1982/10/1',
|
585 |
|
|
),
|
586 |
85ad3d82
|
Assos Assos
|
),
|
587 |
|
|
|
588 |
|
|
// Test email components.
|
589 |
|
|
'email' => array(
|
590 |
|
|
'component' => array(
|
591 |
|
|
'form_key' => 'email',
|
592 |
|
|
'name' => 'E-mail',
|
593 |
|
|
'type' => 'email',
|
594 |
a45e4bc1
|
Assos Assos
|
'value' => '[current-user:mail]',
|
595 |
|
|
'required' => '0',
|
596 |
85ad3d82
|
Assos Assos
|
'extra' => array(
|
597 |
|
|
// SimpleTest does not support type="email" input fields.
|
598 |
|
|
'attributes' => array('type' => 'text'),
|
599 |
|
|
),
|
600 |
|
|
'pid' => '0',
|
601 |
|
|
'weight' => '-5',
|
602 |
|
|
),
|
603 |
|
|
'sample values' => 'admin@localhost.localhost',
|
604 |
|
|
'database values' => array('admin@localhost.localhost'),
|
605 |
|
|
'database default values' => array($this->webform_users['admin']->mail),
|
606 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
607 |
|
|
'match conditional values' => array(
|
608 |
|
|
'equal' => 'admin@localhost.localhost',
|
609 |
|
|
'not_equal' => '',
|
610 |
|
|
'contains' => 'admin',
|
611 |
|
|
'does_not_contain' => 'foo',
|
612 |
|
|
'begins_with' => 'admin',
|
613 |
|
|
'ends_with' => 'localhost',
|
614 |
|
|
'not_empty' => TRUE,
|
615 |
|
|
),
|
616 |
|
|
'mismatch conditional values' => array(
|
617 |
|
|
'equal' => 'foo@localhost.localhost',
|
618 |
|
|
'not_equal' => 'admin@localhost.localhost',
|
619 |
|
|
'contains' => 'foo',
|
620 |
|
|
'does_not_contain' => 'admin',
|
621 |
|
|
'begins_with' => 'localhost',
|
622 |
|
|
'ends_with' => 'admin',
|
623 |
|
|
'empty' => TRUE,
|
624 |
|
|
),
|
625 |
85ad3d82
|
Assos Assos
|
),
|
626 |
|
|
|
627 |
|
|
// Test hidden components.
|
628 |
|
|
'hidden' => array(
|
629 |
|
|
'component' => array(
|
630 |
|
|
'form_key' => 'hidden',
|
631 |
|
|
'name' => 'Hidden',
|
632 |
|
|
'type' => 'hidden',
|
633 |
|
|
'value' => 'default hidden value',
|
634 |
a45e4bc1
|
Assos Assos
|
'required' => '1',
|
635 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
636 |
|
|
'weight' => '-4',
|
637 |
|
|
),
|
638 |
|
|
'sample values' => NULL,
|
639 |
|
|
'database values' => array('default hidden value'),
|
640 |
|
|
'database default values' => array('default hidden value'),
|
641 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
642 |
|
|
'match conditional values' => array(
|
643 |
|
|
'equal' => 'default hidden value',
|
644 |
|
|
'not_equal' => '',
|
645 |
|
|
'contains' => 'hidden',
|
646 |
|
|
'does_not_contain' => 'foo',
|
647 |
|
|
'begins_with' => 'default',
|
648 |
|
|
'ends_with' => 'value',
|
649 |
|
|
'not_empty' => TRUE,
|
650 |
|
|
),
|
651 |
|
|
'mismatch conditional values' => array(
|
652 |
|
|
'equal' => '',
|
653 |
|
|
'not_equal' => 'default hidden value',
|
654 |
|
|
'contains' => 'foo',
|
655 |
|
|
'does_not_contain' => 'hidden',
|
656 |
|
|
'begins_with' => 'value',
|
657 |
|
|
'ends_with' => 'default',
|
658 |
|
|
'empty' => TRUE,
|
659 |
|
|
),
|
660 |
85ad3d82
|
Assos Assos
|
),
|
661 |
|
|
|
662 |
|
|
// Test textarea components.
|
663 |
|
|
'textarea' => array(
|
664 |
|
|
'component' => array(
|
665 |
|
|
'form_key' => 'textarea',
|
666 |
|
|
'name' => 'Textarea',
|
667 |
|
|
'type' => 'textarea',
|
668 |
|
|
'value' => 'sample textarea default value',
|
669 |
|
|
'extra' => array(),
|
670 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
671 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
672 |
|
|
'weight' => '15',
|
673 |
|
|
),
|
674 |
|
|
'sample values' => 'sample textarea value',
|
675 |
|
|
'database values' => array('sample textarea value'),
|
676 |
|
|
'database default values' => array('sample textarea default value'),
|
677 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
678 |
|
|
'match conditional values' => array(
|
679 |
|
|
'equal' => 'sample textarea value',
|
680 |
|
|
'not_equal' => '',
|
681 |
|
|
'contains' => 'sample',
|
682 |
|
|
'does_not_contain' => 'foo',
|
683 |
|
|
'begins_with' => 'sample',
|
684 |
|
|
'ends_with' => 'value',
|
685 |
|
|
'not_empty' => TRUE,
|
686 |
|
|
),
|
687 |
|
|
'mismatch conditional values' => array(
|
688 |
|
|
'equal' => '',
|
689 |
|
|
'not_equal' => 'sample textarea value',
|
690 |
|
|
'contains' => 'foo',
|
691 |
|
|
'does_not_contain' => 'sample',
|
692 |
|
|
'begins_with' => 'value',
|
693 |
|
|
'ends_with' => 'sample',
|
694 |
|
|
'empty' => TRUE,
|
695 |
|
|
),
|
696 |
85ad3d82
|
Assos Assos
|
),
|
697 |
|
|
|
698 |
|
|
// Test textfield components.
|
699 |
a45e4bc1
|
Assos Assos
|
'textfield' => array(
|
700 |
|
|
'component' => array(
|
701 |
|
|
'form_key' => 'textfield',
|
702 |
|
|
'name' => 'Textfield',
|
703 |
|
|
'type' => 'textfield',
|
704 |
|
|
'value' => '',
|
705 |
|
|
'required' => '0',
|
706 |
|
|
'pid' => '0',
|
707 |
|
|
'weight' => '-14',
|
708 |
|
|
),
|
709 |
|
|
'sample values' => '',
|
710 |
|
|
'database values' => array(''),
|
711 |
|
|
'database default values' => array(''),
|
712 |
|
|
),
|
713 |
85ad3d82
|
Assos Assos
|
'textfield_disabled' => array(
|
714 |
|
|
'component' => array(
|
715 |
|
|
'form_key' => 'textfield_disabled',
|
716 |
|
|
'name' => 'Textfield Disabled',
|
717 |
|
|
'type' => 'textfield',
|
718 |
a45e4bc1
|
Assos Assos
|
'value' => '[current-page:query:foo]',
|
719 |
85ad3d82
|
Assos Assos
|
'extra' => array(
|
720 |
|
|
'disabled' => 1,
|
721 |
|
|
),
|
722 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
723 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
724 |
|
|
'weight' => '-15',
|
725 |
|
|
),
|
726 |
a45e4bc1
|
Assos Assos
|
// Manually hard-code the input if token is not available.
|
727 |
8c72e82a
|
Assos Assos
|
// @todo: Update after http://drupal.org/node/1347790 is finished.
|
728 |
a45e4bc1
|
Assos Assos
|
'sample values' => module_exists('token') ? NULL : 'bar',
|
729 |
85ad3d82
|
Assos Assos
|
'database values' => array('bar'),
|
730 |
a45e4bc1
|
Assos Assos
|
'database default values' => module_exists('token') ? array('bar') : array(''),
|
731 |
85ad3d82
|
Assos Assos
|
),
|
732 |
|
|
'textfield_profile' => array(
|
733 |
|
|
'component' => array(
|
734 |
|
|
'form_key' => 'textfield_profile',
|
735 |
|
|
'name' => 'Textfield Profile',
|
736 |
|
|
'type' => 'textfield',
|
737 |
a45e4bc1
|
Assos Assos
|
'value' => '[current-user:gender]',
|
738 |
85ad3d82
|
Assos Assos
|
'extra' => array(
|
739 |
|
|
'width' => '20',
|
740 |
|
|
),
|
741 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
742 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
743 |
|
|
'weight' => '-6',
|
744 |
|
|
),
|
745 |
|
|
'sample values' => 'Female',
|
746 |
|
|
'database values' => array('Female'),
|
747 |
a45e4bc1
|
Assos Assos
|
// The default value will be blank if token does not exist.
|
748 |
8c72e82a
|
Assos Assos
|
// @todo: Update after http://drupal.org/node/1347790 is finished.
|
749 |
a45e4bc1
|
Assos Assos
|
'database default values' => module_exists('token') ? array($this->webform_users['admin']->gender[LANGUAGE_NONE][0]['value']) : array(''),
|
750 |
85ad3d82
|
Assos Assos
|
),
|
751 |
|
|
|
752 |
|
|
// Test time components.
|
753 |
|
|
'time' => array(
|
754 |
|
|
'component' => array(
|
755 |
|
|
'form_key' => 'time',
|
756 |
|
|
'name' => 'Time',
|
757 |
|
|
'type' => 'time',
|
758 |
|
|
'value' => '10:30pm',
|
759 |
|
|
'extra' => array(
|
760 |
|
|
'timezone' => 'site',
|
761 |
|
|
'hourformat' => '12-hour',
|
762 |
|
|
),
|
763 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
764 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
765 |
|
|
'weight' => '16',
|
766 |
|
|
),
|
767 |
a45e4bc1
|
Assos Assos
|
'sample values' => array('hour' => '12', 'minute' => '0', 'ampm' => 'pm'),
|
768 |
|
|
'database values' => array('12:00:00'),
|
769 |
85ad3d82
|
Assos Assos
|
'database default values' => array('22:30:00'),
|
770 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
771 |
|
|
'match conditional values' => array(
|
772 |
|
|
'equal' => '12:00pm',
|
773 |
|
|
'before' => '1:00pm',
|
774 |
|
|
'before_equal' => '12:00pm',
|
775 |
|
|
'after' => '11:00am',
|
776 |
|
|
'after_equal' => '11:00am',
|
777 |
|
|
),
|
778 |
|
|
'mismatch conditional values' => array(
|
779 |
|
|
'equal' => '12:00am',
|
780 |
|
|
'before' => '12:00pm',
|
781 |
|
|
'before_equal' => '11:00am',
|
782 |
|
|
'after' => '12:00pm',
|
783 |
|
|
),
|
784 |
85ad3d82
|
Assos Assos
|
),
|
785 |
|
|
'time_24h' => array(
|
786 |
|
|
'component' => array(
|
787 |
|
|
'form_key' => 'time_24h',
|
788 |
|
|
'name' => 'Time 24H',
|
789 |
|
|
'type' => 'time',
|
790 |
|
|
'value' => '10:30pm',
|
791 |
|
|
'extra' => array(
|
792 |
|
|
'timezone' => 'site',
|
793 |
|
|
'hourformat' => '24-hour',
|
794 |
|
|
),
|
795 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
796 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
797 |
|
|
'weight' => '17',
|
798 |
|
|
),
|
799 |
|
|
'sample values' => array('hour' => '5', 'minute' => '0'),
|
800 |
|
|
'database values' => array('05:00:00'),
|
801 |
|
|
'database default values' => array('22:30:00'),
|
802 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
803 |
|
|
'match conditional values' => array(
|
804 |
|
|
'equal' => '5:00',
|
805 |
|
|
'before' => '24:00',
|
806 |
|
|
'before_equal' => '5:00',
|
807 |
|
|
'after' => '00:00',
|
808 |
|
|
'after_equal' => '00:00',
|
809 |
|
|
),
|
810 |
|
|
'mismatch conditional values' => array(
|
811 |
|
|
'equal' => '5:01',
|
812 |
|
|
'before' => '5:00',
|
813 |
|
|
'before_equal' => '4:59',
|
814 |
|
|
'after' => '5:00',
|
815 |
|
|
'after_equal' => '5:01',
|
816 |
|
|
),
|
817 |
85ad3d82
|
Assos Assos
|
),
|
818 |
|
|
|
819 |
|
|
// Test number components.
|
820 |
|
|
'integer' => array(
|
821 |
|
|
'component' => array(
|
822 |
|
|
'form_key' => 'integer',
|
823 |
|
|
'name' => 'Integer',
|
824 |
|
|
'type' => 'number',
|
825 |
|
|
'value' => '1',
|
826 |
|
|
'extra' => array(
|
827 |
|
|
'type' => 'textfield',
|
828 |
|
|
'integer' => 1,
|
829 |
|
|
'max' => '100',
|
830 |
|
|
// SimpleTest does not support type="number" input fields.
|
831 |
|
|
'attributes' => array('type' => 'text'),
|
832 |
|
|
),
|
833 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
834 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
835 |
|
|
'weight' => '18',
|
836 |
|
|
),
|
837 |
|
|
'sample values' => '2',
|
838 |
|
|
'database values' => array('2'),
|
839 |
|
|
'database default values' => array('1'),
|
840 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
841 |
|
|
'match conditional values' => array(
|
842 |
|
|
'equal' => '2',
|
843 |
|
|
'not_equal' => '0',
|
844 |
|
|
'less_than' => '3',
|
845 |
|
|
'less_than_equal' => '2',
|
846 |
|
|
'greater_than' => '1',
|
847 |
|
|
'greater_than_equal' => '1',
|
848 |
|
|
'not_empty' => TRUE,
|
849 |
|
|
),
|
850 |
|
|
'mismatch conditional values' => array(
|
851 |
|
|
'equal' => '0',
|
852 |
|
|
'not_equal' => '2',
|
853 |
|
|
'less_than' => '2',
|
854 |
|
|
'less_than_equal' => '1',
|
855 |
|
|
'greater_than' => '2',
|
856 |
|
|
'greater_than_equal' => '3',
|
857 |
|
|
'empty' => TRUE,
|
858 |
|
|
),
|
859 |
85ad3d82
|
Assos Assos
|
'error values' => array(
|
860 |
a45e4bc1
|
Assos Assos
|
'1.5' => t('!name field value of @value must be an integer.', array('!name' => 'Integer', '@value' => '1.5')),
|
861 |
|
|
'101' => t('!name field value must be less than @max.', array('!name' => 'Integer', '@max' => '100')),
|
862 |
85ad3d82
|
Assos Assos
|
),
|
863 |
|
|
),
|
864 |
|
|
'integer_range' => array(
|
865 |
|
|
'component' => array(
|
866 |
|
|
'form_key' => 'integer_range',
|
867 |
|
|
'name' => 'Integer Range',
|
868 |
|
|
'type' => 'number',
|
869 |
|
|
'value' => '50',
|
870 |
|
|
'extra' => array(
|
871 |
|
|
'type' => 'select',
|
872 |
|
|
'min' => '10',
|
873 |
|
|
'max' => '50',
|
874 |
|
|
'step' => 5,
|
875 |
|
|
'integer' => 1,
|
876 |
|
|
),
|
877 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
878 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
879 |
|
|
'weight' => '19',
|
880 |
|
|
),
|
881 |
|
|
'sample values' => '10',
|
882 |
|
|
'database values' => array('10'),
|
883 |
|
|
'database default values' => array('50'),
|
884 |
|
|
),
|
885 |
|
|
'decimal_positive' => array(
|
886 |
|
|
'component' => array(
|
887 |
|
|
'form_key' => 'decimal_positive',
|
888 |
|
|
'name' => 'Decimal positive',
|
889 |
|
|
'type' => 'number',
|
890 |
|
|
'value' => '1',
|
891 |
|
|
'extra' => array(
|
892 |
|
|
'type' => 'textfield',
|
893 |
|
|
'field_prefix' => '$',
|
894 |
|
|
'field_suffix' => 'lbs',
|
895 |
|
|
'min' => '0',
|
896 |
|
|
'decimals' => '2',
|
897 |
|
|
'point' => '.',
|
898 |
|
|
'separator' => ',',
|
899 |
|
|
// SimpleTest does not support type="number" input fields.
|
900 |
|
|
'attributes' => array('type' => 'text'),
|
901 |
|
|
),
|
902 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
903 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
904 |
|
|
'weight' => '20',
|
905 |
|
|
),
|
906 |
|
|
'sample values' => '2.00',
|
907 |
|
|
'database values' => array('2.00'),
|
908 |
|
|
'database default values' => array('1'),
|
909 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
910 |
|
|
'match conditional values' => array(
|
911 |
|
|
'equal' => '2',
|
912 |
|
|
'not_equal' => '0',
|
913 |
|
|
'less_than' => '3.000',
|
914 |
|
|
'greater_than' => '1.000',
|
915 |
|
|
'not_empty' => TRUE,
|
916 |
|
|
),
|
917 |
|
|
'mismatch conditional values' => array(
|
918 |
|
|
'equal' => '0',
|
919 |
|
|
'not_equal' => '2',
|
920 |
|
|
'less_than' => '2.0',
|
921 |
|
|
'greater_than' => '2.00',
|
922 |
|
|
'empty' => TRUE,
|
923 |
|
|
),
|
924 |
85ad3d82
|
Assos Assos
|
'error values' => array(
|
925 |
a45e4bc1
|
Assos Assos
|
'-1' => t('!name field value must be greater than @min.', array('!name' => 'Decimal positive', '@min' => '0')),
|
926 |
85ad3d82
|
Assos Assos
|
),
|
927 |
|
|
),
|
928 |
|
|
'decimal_range' => array(
|
929 |
|
|
'component' => array(
|
930 |
|
|
'form_key' => 'decimal_range',
|
931 |
|
|
'name' => 'Decimal range',
|
932 |
|
|
'type' => 'number',
|
933 |
|
|
'value' => '1',
|
934 |
|
|
'extra' => array(
|
935 |
|
|
'type' => 'textfield',
|
936 |
|
|
'field_prefix' => '$',
|
937 |
|
|
'field_suffix' => 'lbs',
|
938 |
|
|
'min' => '1',
|
939 |
|
|
'max' => '12',
|
940 |
|
|
'step' => '1.5',
|
941 |
|
|
// SimpleTest does not support type="number" input fields.
|
942 |
|
|
'attributes' => array('type' => 'text'),
|
943 |
|
|
),
|
944 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
945 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
946 |
|
|
'weight' => '21',
|
947 |
|
|
),
|
948 |
|
|
'sample values' => '11.5',
|
949 |
|
|
'database values' => array('11.5'),
|
950 |
|
|
'database default values' => array('1'),
|
951 |
|
|
'error values' => array(
|
952 |
a45e4bc1
|
Assos Assos
|
'2' => t('!name field value must be @start plus a multiple of @step.', array('!name' => 'Decimal range', '@start' => '1', '@step' => '1.5')),
|
953 |
|
|
'13' => t('!name field value of @value should be in the range @min to @max.', array('!name' => 'Decimal range', '@value' => '13', '@min' => '1', '@max' => '12')),
|
954 |
85ad3d82
|
Assos Assos
|
),
|
955 |
|
|
),
|
956 |
|
|
'decimal_range_select' => array(
|
957 |
|
|
'component' => array(
|
958 |
|
|
'form_key' => 'decimal_range_select',
|
959 |
|
|
'name' => 'Decimal range select',
|
960 |
|
|
'type' => 'number',
|
961 |
|
|
'value' => '1',
|
962 |
|
|
'extra' => array(
|
963 |
|
|
'type' => 'select',
|
964 |
|
|
'field_prefix' => '$',
|
965 |
|
|
'field_suffix' => 'lbs',
|
966 |
|
|
'min' => '1',
|
967 |
|
|
'max' => '12',
|
968 |
|
|
'step' => '1.5',
|
969 |
|
|
),
|
970 |
a45e4bc1
|
Assos Assos
|
'required' => '0',
|
971 |
85ad3d82
|
Assos Assos
|
'pid' => '0',
|
972 |
|
|
'weight' => '21',
|
973 |
|
|
),
|
974 |
a45e4bc1
|
Assos Assos
|
'sample values' => '10',
|
975 |
|
|
'database values' => array('10'),
|
976 |
85ad3d82
|
Assos Assos
|
'database default values' => array('1'),
|
977 |
a45e4bc1
|
Assos Assos
|
// Conditionals match against the 'sample values'.
|
978 |
|
|
'match conditional values' => array(
|
979 |
|
|
'equal' => '10',
|
980 |
|
|
'not_equal' => '2.5',
|
981 |
|
|
'less_than' => '11.5',
|
982 |
|
|
'greater_than' => '1',
|
983 |
|
|
),
|
984 |
|
|
'mismatch conditional values' => array(
|
985 |
|
|
'equal' => '2.5',
|
986 |
|
|
'not_equal' => '10',
|
987 |
|
|
'less_than' => '10',
|
988 |
|
|
'greater_than' => '11.5',
|
989 |
|
|
),
|
990 |
85ad3d82
|
Assos Assos
|
),
|
991 |
|
|
);
|
992 |
|
|
|
993 |
|
|
return $this->_webform_components;
|
994 |
|
|
}
|
995 |
|
|
|
996 |
feca1e4a
|
Assos Assos
|
/**
|
997 |
|
|
*
|
998 |
|
|
*/
|
999 |
|
|
public function webformForm() {
|
1000 |
85ad3d82
|
Assos Assos
|
if (isset($this->_webform_node)) {
|
1001 |
|
|
return $this->_webform_node;
|
1002 |
|
|
}
|
1003 |
|
|
|
1004 |
|
|
$settings = array(
|
1005 |
feca1e4a
|
Assos Assos
|
'type' => 'webform',
|
1006 |
|
|
'language' => LANGUAGE_NONE,
|
1007 |
|
|
'uid' => '1',
|
1008 |
|
|
'status' => '1',
|
1009 |
|
|
'promote' => '1',
|
1010 |
|
|
'moderate' => '0',
|
1011 |
|
|
'sticky' => '0',
|
1012 |
|
|
'tnid' => '0',
|
1013 |
|
|
'translate' => '0',
|
1014 |
|
|
'title' => 'Test Webform',
|
1015 |
|
|
'log' => '',
|
1016 |
|
|
'format' => '1',
|
1017 |
|
|
'webform' => array(
|
1018 |
85ad3d82
|
Assos Assos
|
'confirmation' => 'Thanks!',
|
1019 |
a45e4bc1
|
Assos Assos
|
) + webform_node_defaults(),
|
1020 |
85ad3d82
|
Assos Assos
|
);
|
1021 |
|
|
|
1022 |
|
|
$cid = 0;
|
1023 |
8c72e82a
|
Assos Assos
|
foreach ($this->webformComponents() as $key => $component_info) {
|
1024 |
85ad3d82
|
Assos Assos
|
$cid++;
|
1025 |
|
|
$settings['webform']['components'][$cid] = $component_info['component'];
|
1026 |
|
|
$settings['webform']['components'][$cid]['cid'] = $cid;
|
1027 |
|
|
$settings['webform']['components'][$cid]['pid'] = 0;
|
1028 |
|
|
}
|
1029 |
|
|
|
1030 |
|
|
$this->_webform_node = $this->drupalCreateNode($settings);
|
1031 |
|
|
|
1032 |
|
|
return $this->_webform_node;
|
1033 |
|
|
}
|
1034 |
|
|
|
1035 |
|
|
/**
|
1036 |
|
|
* Generate a list of all values that would result in a valid submission.
|
1037 |
a45e4bc1
|
Assos Assos
|
*
|
1038 |
|
|
* @param $input_values
|
1039 |
|
|
* An array of input values keyed by the component form key. If none
|
1040 |
8c72e82a
|
Assos Assos
|
* are specified, the defaults will be pulled from webformComponents().
|
1041 |
85ad3d82
|
Assos Assos
|
*/
|
1042 |
feca1e4a
|
Assos Assos
|
public function webformPost($input_values = NULL) {
|
1043 |
85ad3d82
|
Assos Assos
|
$edit = array();
|
1044 |
a45e4bc1
|
Assos Assos
|
|
1045 |
|
|
if (empty($input_values)) {
|
1046 |
|
|
$input_values = array();
|
1047 |
8c72e82a
|
Assos Assos
|
foreach ($this->webformComponents() as $key => $component_info) {
|
1048 |
a45e4bc1
|
Assos Assos
|
$input_values[$key] = $component_info['sample values'];
|
1049 |
|
|
}
|
1050 |
|
|
}
|
1051 |
|
|
|
1052 |
|
|
foreach ($input_values as $key => $values) {
|
1053 |
|
|
if (is_array($values)) {
|
1054 |
|
|
foreach ($values as $subkey => $value) {
|
1055 |
85ad3d82
|
Assos Assos
|
$edit["submitted[$key][$subkey]"] = $value;
|
1056 |
|
|
}
|
1057 |
|
|
}
|
1058 |
a45e4bc1
|
Assos Assos
|
elseif ($values != NULL) {
|
1059 |
|
|
$value = $values;
|
1060 |
85ad3d82
|
Assos Assos
|
// Multiple selects have a funky extra empty bracket in the name.
|
1061 |
|
|
$extra = $key == 'select_multiple' ? '[]' : '';
|
1062 |
|
|
$edit["submitted[$key]$extra"] = $value;
|
1063 |
|
|
}
|
1064 |
|
|
}
|
1065 |
|
|
return $edit;
|
1066 |
|
|
}
|
1067 |
|
|
|
1068 |
|
|
/**
|
1069 |
|
|
* Utility function to print out the current page being tested.
|
1070 |
|
|
*/
|
1071 |
feca1e4a
|
Assos Assos
|
public function webformPrintPage() {
|
1072 |
85ad3d82
|
Assos Assos
|
$this->verbose($this->drupalGetContent());
|
1073 |
|
|
}
|
1074 |
feca1e4a
|
Assos Assos
|
|
1075 |
85ad3d82
|
Assos Assos
|
} |