Projet

Général

Profil

Révision a45e4bc1

Ajouté par Assos Assos il y a environ 9 ans

Update webform to 4.10

Voir les différences:

drupal7/sites/all/modules/webform/tests/webform.test
13 13
  /**
14 14
   * Implements setUp().
15 15
   */
16
  function setUp() {
17
    // Enable Webform.
18
    parent::setUp('webform', 'profile');
16
  function setUp($added_modules = array()) {
17
    // Enable Webform and Token module if available.
18
    if (module_exists('token')) {
19
      $modules = array('webform', 'token');
20
    }
21
    else {
22
      $modules = array('webform');
23
    }
24
    parent::setUp(array_merge($modules, $added_modules));
19 25

  
20
    // Create a profile field to test %profile tokens.
21
    db_query("INSERT INTO {profile_field} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('Gender', 'profile_gender', '', 'Profile', 'textfield', 0, 0, 0, 2, 0, '', '')");
26
    // Create a profile field to test [user:?] tokens.
27
    $field = array(
28
      'field_name' => 'gender',
29
      'type' => 'text',
30
      'cardinality' => 1,
31
    );
32
    $instance = array(
33
      'field_name' => 'gender',
34
      'entity_type' => 'user',
35
      'bundle' => 'user',
36
      'label' => 'Gender',
37
      'widget' => array(
38
        'type' => 'text_textfield',
39
        'label' => 'Gender',
40
      ),
41
    );
42
    field_create_field($field);
43
    field_create_instance($instance);
22 44

  
23 45
    // Create a normal user that can view their own submissions.
24 46
    $permissions['userAccess'] = array(
......
53 75

  
54 76
    foreach ($permissions as $user_key => $role_permissions) {
55 77
      $this->webform_users[$user_key] = $this->drupalCreateUser($role_permissions);
56
      $profile = array('profile_gender' => 'Female');
57
      $this->webform_users[$user_key]->profile_gender = 'Female';
58
      profile_save_profile($profile, $this->webform_users[$user_key], 'Profile');
78
      $this->webform_users[$user_key]->gender = array(LANGUAGE_NONE => array(array('value' => 'Female')));
79
      user_save($this->webform_users[$user_key]);
59 80
    }
60 81
  }
61 82

  
......
117 138
            'start_date' => '-100 years',
118 139
            'end_date' => '+2 years',
119 140
          ),
120
          'mandatory' => '0',
141
          'required' => '0',
121 142
          'pid' => '0',
122 143
          'weight' => '-15',
123 144
        ),
124 145
        'sample values' => array('day' => '30', 'month' => '9', 'year' => '1982'),
125 146
        'database values' => array('1982-09-30'),
126 147
        'database default values' => array('1978-11-19'),
148
        // Conditionals match against the 'sample values'.
149
        'match conditional values' => array(
150
          'equal' => '1982/9/30',
151
          'before' => '1982/10/1',
152
          'before_equal' => '1982/9/30',
153
          'after' => '1982/9/29',
154
          'after_equal' => '1982/9/29',
155
        ),
156
        'mismatch conditional values' => array(
157
          'equal' => '1981/9/30',
158
          'before' => '1982/9/30',
159
          'before_equal' => '1982/9/29',
160
          'after' => '1982/9/30',
161
          'after_equal' => '1982/10/1',
162
        ),
127 163
      ),
128 164

  
129 165
      // Test grid components.
......
137 173
            'questions' => "0|Ålphå\n1|ıé†å\n2|Î鬆å", // Left side
138 174
            'options' => "0|øne\n1|twö\n2|ǼBƇ\n3|€Euro", // Top
139 175
          ),
140
          'mandatory' => '0',
176
          'required' => '0',
141 177
          'pid' => '2',
142 178
          'weight' => '-19',
143 179
        ),
......
155 191
            'questions' => "one|What's your option?\ntwo|Agåin?\nthree|One more time!", // Left side.
156 192
            'options' => "one|Option one\ntwo|Option 2\nthree| Three is me", // Top
157 193
          ),
158
          'mandatory' => '0',
194
          'required' => '0',
159 195
          'pid' => '0',
160 196
          'weight' => '-15',
161 197
        ),
......
175 211
            'items' => "one|one\ntwo|two\nthree|three",
176 212
            'multiple' => 1,
177 213
          ),
178
          'mandatory' => '0',
214
          'required' => '0',
179 215
          'pid' => '0',
180 216
          'weight' => '-15',
181 217
        ),
182 218
        'sample values' => array('one' => TRUE, 'two' => FALSE, 'three' => TRUE),
183 219
        'database values' => array('one', 'three'),
184 220
        'database default values' => array('two'),
221
        // Conditionals match against the 'sample values'.
222
        'match conditional values' => array(
223
          'equal' => array('one', 'three'), // ANDed together match.
224
          'not_equal' => array('two'),
225
        ),
226
        'mismatch conditional values' => array(
227
          'equal' => array('one', 'two'),
228
          'not_equal' => array('two', 'three'),
229
        ),
185 230
      ),
186 231
      'checkboxes_zero' => array(
187 232
        'component' => array(
......
193 238
            'items' => "0|zero\n1|one\n2|two",
194 239
            'multiple' => 1,
195 240
          ),
196
          'mandatory' => '1',
241
          'required' => '1',
197 242
          'pid' => '0',
198 243
          'weight' => '-9',
199 244
        ),
200 245
        'sample values' => array('0' => TRUE),
201 246
        'database values' => array('0'),
202 247
        'database default values' => array('0'),
248
        // Conditionals match against the 'sample values'.
249
        'match conditional values' => array(
250
          'equal' => '0',
251
          'not_equal' => '1',
252
        ),
253
        'mismatch conditional values' => array(
254
          'equal' => '1',
255
          'not_equal' => '0',
256
        ),
203 257
      ),
204 258
      'radios' => array(
205 259
        'component' => array(
......
210 264
          'extra' => array(
211 265
            'items' => "one|one\ntwo|two\nthree|three",
212 266
          ),
213
          'mandatory' => '1',
267
          'required' => '1',
214 268
          'pid' => '0',
215 269
          'weight' => '-9',
216 270
        ),
217 271
        'sample values' => 'one',
218 272
        'database values' => array('one'),
219 273
        'database default values' => array('two'),
274
        // Conditionals match against the 'sample values'.
275
        'match conditional values' => array(
276
          'equal' => 'one',
277
          'not_equal' => 'two',
278
        ),
279
        'mismatch conditional values' => array(
280
          'equal' => 'two',
281
          'not_equal' => 'one',
282
        ),
220 283
      ),
221 284
      'radios_zero' => array(
222 285
        'component' => array(
......
227 290
          'extra' => array(
228 291
            'items' => "0|zero\n1|one\n2|two",
229 292
          ),
230
          'mandatory' => '1',
293
          'required' => '1',
231 294
          'pid' => '0',
232 295
          'weight' => '-9',
233 296
        ),
234 297
        'sample values' => '0',
235 298
        'database values' => array('0'),
236 299
        'database default values' => array('0'),
300
        // Conditionals match against the 'sample values'.
301
        'match conditional values' => array(
302
          'equal' => '0',
303
          'not_equal' => '1',
304
        ),
305
        'mismatch conditional values' => array(
306
          'equal' => '1',
307
          'not_equal' => '0',
308
        ),
309
      ),
310
      'radios_relative' => array(
311
        'component' => array(
312
          'form_key' => 'radios_relative',
313
          'name' => 'Radios relative',
314
          'type' => 'select',
315
          'value' => 'one',
316
          'extra' => array(
317
            'items' => "zero|Zero\none|One\ntwo|Two\nthree|Three\n",
318
          ),
319
          'required' => '1',
320
          'pid' => '0',
321
          'weight' => '-9',
322
        ),
323
        'sample values' => 'one',
324
        'database values' => array('one'),
325
        'database default values' => array('one'),
326
        // Conditionals match against the 'sample values'.
327
        'match conditional values' => array(
328
          'equal' => 'one',
329
          'not_equal' => 'zero',
330
          'less_than' => 'two',
331
          'less_than_equal' => 'one',
332
          'greater_than' => 'zero',
333
          'greater_than_equal' => 'zero',
334
        ),
335
        'mismatch conditional values' => array(
336
          'equal' => 'zero',
337
          'not_equal' => 'one',
338
          'less_than' => 'one',
339
          'less_than_equal' => 'zero',
340
          'greater_than' => 'two',
341
          'greater_than_equal' => 'two',
342
        ),
237 343
      ),
238 344
      'select' => array(
239 345
        'component' => array(
......
246 352
            'items' => "one|one\ntwo|two\nthree|three\nfour|four\nfive|five\nsix|six",
247 353
            'aslist' => 1,
248 354
          ),
249
          'mandatory' => '1',
355
          'required' => '1',
250 356
          'pid' => '0',
251 357
          'weight' => '-15',
252 358
        ),
253 359
        'sample values' => 'two',
254 360
        'database values' => array('two'),
255 361
        'database default values' => array('one'),
362
        // Conditionals match against the 'sample values'.
363
        'match conditional values' => array(
364
          'equal' => 'two',
365
          'not_equal' => 'one',
366
        ),
367
        'mismatch conditional values' => array(
368
          'equal' => 'one',
369
          'not_equal' => 'two',
370
        ),
256 371
      ),
257 372
      'select_zero' => array(
258 373
        'component' => array(
......
265 380
            'items' => "0|zero\n1|one\n2|two",
266 381
            'aslist' => 1,
267 382
          ),
268
          'mandatory' => '1',
383
          'required' => '1',
269 384
          'pid' => '0',
270 385
          'weight' => '-15',
271 386
        ),
272 387
        'sample values' => '0',
273 388
        'database values' => array('0'),
274 389
        'database default values' => array('0'),
390
        // Conditionals match against the 'sample values'.
391
        'match conditional values' => array(
392
          'equal' => '0',
393
          'not_equal' => '1',
394
        ),
395
        'mismatch conditional values' => array(
396
          'equal' => '1',
397
          'not_equal' => '0',
398
        ),
275 399
      ),
276 400
      'select_no_default' => array(
277 401
        'component' => array(
......
284 408
            'items' => "one|one\ntwo|two\nthree|three\nfour|four\nfive|five\nsix|six",
285 409
            'aslist' => 1,
286 410
          ),
287
          'mandatory' => '0',
411
          'required' => '0',
288 412
          'pid' => '0',
289 413
          'weight' => '-15',
290 414
        ),
291 415
        'sample values' => 'two',
292 416
        'database values' => array('two'),
293 417
        'database default values' => array(''),
418
        // Conditionals match against the 'sample values'.
419
        'match conditional values' => array(
420
          'equal' => 'two',
421
          'not_equal' => '',
422
        ),
423
        'mismatch conditional values' => array(
424
          'equal' => '',
425
          'not_equal' => 'two',
426
        ),
294 427
      ),
295 428
      'select_no_default_zero' => array(
296 429
        'component' => array(
......
303 436
            'items' => "0|zero\n1|one\n2|two",
304 437
            'aslist' => 1,
305 438
          ),
306
          'mandatory' => '0',
439
          'required' => '0',
307 440
          'pid' => '0',
308 441
          'weight' => '-15',
309 442
        ),
310 443
        'sample values' => '0',
311 444
        'database values' => array('0'),
312 445
        'database default values' => array(''),
446
        // Conditionals match against the 'sample values'.
447
        'match conditional values' => array(
448
          'equal' => '0',
449
          'not_equal' => '',
450
        ),
451
        'mismatch conditional values' => array(
452
          'equal' => '',
453
          'not_equal' => '0',
454
        ),
313 455
      ),
314 456
      'select_optgroup' => array(
315 457
        'component' => array(
......
322 464
            '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",
323 465
            'aslist' => 1,
324 466
          ),
325
          'mandatory' => '1',
467
          'required' => '1',
326 468
          'pid' => '0',
327 469
          'weight' => '-15',
328 470
        ),
......
339 481
          'extra' => array(
340 482
            'items' => "nate@localhost.localhost|one\nadmin@localhost.localhost|two",
341 483
          ),
342
          'mandatory' => '0',
484
          'required' => '0',
343 485
          'pid' => '2',
344 486
          'weight' => '-17',
345 487
        ),
......
358 500
            'multiple' => 1,
359 501
            'aslist' => 1,
360 502
          ),
361
          'mandatory' => '0',
503
          'required' => '0',
362 504
          'pid' => '0',
363 505
          'weight' => '-10',
364 506
        ),
......
367 509
        'database values' => array('one', 'two'),
368 510
        'database default values' => array('one', 'two'),
369 511
      ),
512
      'select_relative' => array(
513
        'component' => array(
514
          'form_key' => 'select_relative',
515
          'name' => 'Select relative',
516
          'type' => 'select',
517
          'value' => 'one',
518
          'extra' => array(
519
            'items' => "zero|Zero\none|One\ntwo|Two\nthree|Three\n",
520
            'aslist' => 1,
521
          ),
522
          'required' => '1',
523
          'pid' => '0',
524
          'weight' => '-9',
525
        ),
526
        'sample values' => 'one',
527
        'database values' => array('one'),
528
        'database default values' => array('one'),
529
        // Conditionals match against the 'sample values'.
530
        'match conditional values' => array(
531
          'equal' => 'one',
532
          'not_equal' => 'zero',
533
          'less_than' => 'two',
534
          'less_than_equal' => 'one',
535
          'greater_than' => 'zero',
536
          'greater_than_equal' => 'zero',
537
        ),
538
        'mismatch conditional values' => array(
539
          'equal' => 'zero',
540
          'not_equal' => 'one',
541
          'less_than' => 'one',
542
          'less_than_equal' => 'zero',
543
          'greater_than' => 'two',
544
          'greater_than_equal' => 'two',
545
        ),
546
      ),
370 547

  
371 548
      // Test date components.
372 549
      'date_textfield' => array(
......
381 558
            'end_date' => '+2 years',
382 559
            'year_textfield' => 1,
383 560
          ),
384
          'mandatory' => '1',
561
          'required' => '1',
385 562
          'pid' => '0',
386 563
          'weight' => '-7',
387 564
        ),
388 565
        'sample values' => array('day' => '30', 'month' => '9', 'year' => '1982'),
389 566
        'database values' => array('1982-09-30'),
390 567
        'database default values' => array('1978-11-19'),
568
        // Conditionals match against the 'sample values'.
569
        'match conditional values' => array(
570
          'equal' => '1982/9/30',
571
          'before' => '1982/10/1',
572
          'before_equal' => '1982/9/30',
573
          'after' => '1982/9/29',
574
          'after_equal' => '1982/9/29',
575
        ),
576
        'mismatch conditional values' => array(
577
          'equal' => '1981/9/30',
578
          'before' => '1982/9/30',
579
          'before_equal' => '1982/9/29',
580
          'after' => '1982/9/30',
581
          'after_equal' => '1982/10/1',
582
        ),
391 583
      ),
392 584

  
393 585
      // Test email components.
......
396 588
          'form_key' => 'email',
397 589
          'name' => 'E-mail',
398 590
          'type' => 'email',
399
          'value' => '%useremail',
400
          'mandatory' => '0',
591
          'value' => '[current-user:mail]',
592
          'required' => '0',
401 593
          'extra' => array(
402 594
            // SimpleTest does not support type="email" input fields.
403 595
            'attributes' => array('type' => 'text'),
......
408 600
        'sample values' => 'admin@localhost.localhost',
409 601
        'database values' => array('admin@localhost.localhost'),
410 602
        'database default values' => array($this->webform_users['admin']->mail),
603
        // Conditionals match against the 'sample values'.
604
        'match conditional values' => array(
605
          'equal' => 'admin@localhost.localhost',
606
          'not_equal' => '',
607
          'contains' => 'admin',
608
          'does_not_contain' => 'foo',
609
          'begins_with' => 'admin',
610
          'ends_with' => 'localhost',
611
          'not_empty' => TRUE,
612
        ),
613
        'mismatch conditional values' => array(
614
          'equal' => 'foo@localhost.localhost',
615
          'not_equal' => 'admin@localhost.localhost',
616
          'contains' => 'foo',
617
          'does_not_contain' => 'admin',
618
          'begins_with' => 'localhost',
619
          'ends_with' => 'admin',
620
          'empty' => TRUE,
621
        ),
411 622
      ),
412 623

  
413 624
      // Test hidden components.
......
417 628
          'name' => 'Hidden',
418 629
          'type' => 'hidden',
419 630
          'value' => 'default hidden value',
420
          'mandatory' => '1',
631
          'required' => '1',
421 632
          'pid' => '0',
422 633
          'weight' => '-4',
423 634
        ),
424 635
        'sample values' => NULL,
425 636
        'database values' => array('default hidden value'),
426 637
        'database default values' => array('default hidden value'),
638
        // Conditionals match against the 'sample values'.
639
        'match conditional values' => array(
640
          'equal' => 'default hidden value',
641
          'not_equal' => '',
642
          'contains' => 'hidden',
643
          'does_not_contain' => 'foo',
644
          'begins_with' => 'default',
645
          'ends_with' => 'value',
646
          'not_empty' => TRUE,
647
        ),
648
        'mismatch conditional values' => array(
649
          'equal' => '',
650
          'not_equal' => 'default hidden value',
651
          'contains' => 'foo',
652
          'does_not_contain' => 'hidden',
653
          'begins_with' => 'value',
654
          'ends_with' => 'default',
655
          'empty' => TRUE,
656
        ),
427 657
      ),
428 658

  
429 659
      // Test textarea components.
......
434 664
          'type' => 'textarea',
435 665
          'value' => 'sample textarea default value',
436 666
          'extra' => array(),
437
          'mandatory' => '0',
667
          'required' => '0',
438 668
          'pid' => '0',
439 669
          'weight' => '15',
440 670
        ),
441 671
        'sample values' => 'sample textarea value',
442 672
        'database values' => array('sample textarea value'),
443 673
        'database default values' => array('sample textarea default value'),
674
        // Conditionals match against the 'sample values'.
675
        'match conditional values' => array(
676
          'equal' => 'sample textarea value',
677
          'not_equal' => '',
678
          'contains' => 'sample',
679
          'does_not_contain' => 'foo',
680
          'begins_with' => 'sample',
681
          'ends_with' => 'value',
682
          'not_empty' => TRUE,
683
        ),
684
        'mismatch conditional values' => array(
685
          'equal' => '',
686
          'not_equal' => 'sample textarea value',
687
          'contains' => 'foo',
688
          'does_not_contain' => 'sample',
689
          'begins_with' => 'value',
690
          'ends_with' => 'sample',
691
          'empty' => TRUE,
692
        ),
444 693
      ),
445 694

  
446 695
      // Test textfield components.
696
      'textfield' => array(
697
        'component' => array(
698
          'form_key' => 'textfield',
699
          'name' => 'Textfield',
700
          'type' => 'textfield',
701
          'value' => '',
702
          'required' => '0',
703
          'pid' => '0',
704
          'weight' => '-14',
705
        ),
706
        'sample values' => '',
707
        'database values' => array(''),
708
        'database default values' => array(''),
709
      ),
447 710
      'textfield_disabled' => array(
448 711
        'component' => array(
449 712
          'form_key' => 'textfield_disabled',
450 713
          'name' => 'Textfield Disabled',
451 714
          'type' => 'textfield',
452
          'value' => '%get[foo]',
715
          'value' => '[current-page:query:foo]',
453 716
          'extra' => array(
454 717
            'disabled' => 1,
455 718
          ),
456
          'mandatory' => '0',
719
          'required' => '0',
457 720
          'pid' => '0',
458 721
          'weight' => '-15',
459 722
        ),
460
        'sample values' => NULL,
723
        // Manually hard-code the input if token is not available.
724
        // TODO: Update after http://drupal.org/node/1347790 is finished.
725
        'sample values' => module_exists('token') ? NULL : 'bar',
461 726
        'database values' => array('bar'),
462
        'database default values' => array('bar'),
727
        'database default values' => module_exists('token') ? array('bar') : array(''),
463 728
      ),
464 729
      'textfield_profile' => array(
465 730
        'component' => array(
466 731
          'form_key' => 'textfield_profile',
467 732
          'name' => 'Textfield Profile',
468 733
          'type' => 'textfield',
469
          'value' => '%profile[profile_gender]',
734
          'value' => '[current-user:gender]',
470 735
          'extra' => array(
471 736
            'width' => '20',
472 737
          ),
473
          'mandatory' => '0',
738
          'required' => '0',
474 739
          'pid' => '0',
475 740
          'weight' => '-6',
476 741
        ),
477 742
        'sample values' => 'Female',
478 743
        'database values' => array('Female'),
479
        'database default values' => array($this->webform_users['admin']->profile_gender),
744
        // The default value will be blank if token does not exist.
745
        // TODO: Update after http://drupal.org/node/1347790 is finished.
746
        'database default values' => module_exists('token') ? array($this->webform_users['admin']->gender[LANGUAGE_NONE][0]['value']) : array(''),
480 747
      ),
481 748

  
482 749
      // Test time components.
......
490 757
            'timezone' => 'site',
491 758
            'hourformat' => '12-hour',
492 759
          ),
493
          'mandatory' => '0',
760
          'required' => '0',
494 761
          'pid' => '0',
495 762
          'weight' => '16',
496 763
        ),
497
        'sample values' => array('hour' => '5', 'minute' => '0', 'ampm' => 'am'),
498
        'database values' => array('05:00:00'),
764
        'sample values' => array('hour' => '12', 'minute' => '0', 'ampm' => 'pm'),
765
        'database values' => array('12:00:00'),
499 766
        'database default values' => array('22:30:00'),
767
        // Conditionals match against the 'sample values'.
768
        'match conditional values' => array(
769
          'equal' => '12:00pm',
770
          'before' => '1:00pm',
771
          'before_equal' => '12:00pm',
772
          'after' => '11:00am',
773
          'after_equal' => '11:00am',
774
        ),
775
        'mismatch conditional values' => array(
776
          'equal' => '12:00am',
777
          'before' => '12:00pm',
778
          'before_equal' => '11:00am',
779
          'after' => '12:00pm',
780
        ),
500 781
      ),
501 782
      'time_24h' => array(
502 783
        'component' => array(
......
508 789
            'timezone' => 'site',
509 790
            'hourformat' => '24-hour',
510 791
          ),
511
          'mandatory' => '0',
792
          'required' => '0',
512 793
          'pid' => '0',
513 794
          'weight' => '17',
514 795
        ),
515 796
        'sample values' => array('hour' => '5', 'minute' => '0'),
516 797
        'database values' => array('05:00:00'),
517 798
        'database default values' => array('22:30:00'),
799
        // Conditionals match against the 'sample values'.
800
        'match conditional values' => array(
801
          'equal' => '5:00',
802
          'before' => '24:00',
803
          'before_equal' => '5:00',
804
          'after' => '00:00',
805
          'after_equal' => '00:00',
806
        ),
807
        'mismatch conditional values' => array(
808
          'equal' => '5:01',
809
          'before' => '5:00',
810
          'before_equal' => '4:59',
811
          'after' => '5:00',
812
          'after_equal' => '5:01',
813
        ),
518 814
      ),
519 815

  
520 816
      // Test number components.
......
531 827
            // SimpleTest does not support type="number" input fields.
532 828
            'attributes' => array('type' => 'text'),
533 829
          ),
534
          'mandatory' => '0',
830
          'required' => '0',
535 831
          'pid' => '0',
536 832
          'weight' => '18',
537 833
        ),
538 834
        'sample values' => '2',
539 835
        'database values' => array('2'),
540 836
        'database default values' => array('1'),
837
        // Conditionals match against the 'sample values'.
838
        'match conditional values' => array(
839
          'equal' => '2',
840
          'not_equal' => '0',
841
          'less_than' => '3',
842
          'less_than_equal' => '2',
843
          'greater_than' => '1',
844
          'greater_than_equal' => '1',
845
          'not_empty' => TRUE,
846
        ),
847
        'mismatch conditional values' => array(
848
          'equal' => '0',
849
          'not_equal' => '2',
850
          'less_than' => '2',
851
          'less_than_equal' => '1',
852
          'greater_than' => '2',
853
          'greater_than_equal' => '3',
854
          'empty' => TRUE,
855
        ),
541 856
        'error values' => array(
542
          '1.5' => t('%name field value of @value must be an integer.', array('%name' => 'Integer', '@value' => '1.5')),
543
          '101' => t('%name field value must be less than @max.', array('%name' => 'Integer', '@max' => '100')),
857
          '1.5' => t('!name field value of @value must be an integer.', array('!name' => 'Integer', '@value' => '1.5')),
858
          '101' => t('!name field value must be less than @max.', array('!name' => 'Integer', '@max' => '100')),
544 859
        ),
545 860
      ),
546 861
      'integer_range' => array(
......
556 871
            'step' => 5,
557 872
            'integer' => 1,
558 873
          ),
559
          'mandatory' => '0',
874
          'required' => '0',
560 875
          'pid' => '0',
561 876
          'weight' => '19',
562 877
        ),
......
581 896
            // SimpleTest does not support type="number" input fields.
582 897
            'attributes' => array('type' => 'text'),
583 898
          ),
584
          'mandatory' => '0',
899
          'required' => '0',
585 900
          'pid' => '0',
586 901
          'weight' => '20',
587 902
        ),
588 903
        'sample values' => '2.00',
589 904
        'database values' => array('2.00'),
590 905
        'database default values' => array('1'),
906
        // Conditionals match against the 'sample values'.
907
        'match conditional values' => array(
908
          'equal' => '2',
909
          'not_equal' => '0',
910
          'less_than' => '3.000',
911
          'greater_than' => '1.000',
912
          'not_empty' => TRUE,
913
        ),
914
        'mismatch conditional values' => array(
915
          'equal' => '0',
916
          'not_equal' => '2',
917
          'less_than' => '2.0',
918
          'greater_than' => '2.00',
919
          'empty' => TRUE,
920
        ),
591 921
        'error values' => array(
592
          '-1' => t('%name field value must be greater than @min.', array('%name' => 'Decimal positive', '@min' => '0')),
922
          '-1' => t('!name field value must be greater than @min.', array('!name' => 'Decimal positive', '@min' => '0')),
593 923
        ),
594 924
      ),
595 925
      'decimal_range' => array(
......
608 938
            // SimpleTest does not support type="number" input fields.
609 939
            'attributes' => array('type' => 'text'),
610 940
          ),
611
          'mandatory' => '0',
941
          'required' => '0',
612 942
          'pid' => '0',
613 943
          'weight' => '21',
614 944
        ),
......
616 946
        'database values' => array('11.5'),
617 947
        'database default values' => array('1'),
618 948
        'error values' => array(
619
          '2' => t('%name field value must be @start plus a multiple of @step.', array('%name' => 'Decimal range', '@start' => '1', '@step' => '1.5')),
620
          '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')),
949
          '2' => t('!name field value must be @start plus a multiple of @step.', array('!name' => 'Decimal range', '@start' => '1', '@step' => '1.5')),
950
          '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')),
621 951
        ),
622 952
      ),
623 953
      'decimal_range_select' => array(
......
634 964
            'max' => '12',
635 965
            'step' => '1.5',
636 966
          ),
637
          'mandatory' => '0',
967
          'required' => '0',
638 968
          'pid' => '0',
639 969
          'weight' => '21',
640 970
        ),
641
        'sample values' => '11.5',
642
        'database values' => array('11.5'),
971
        'sample values' => '10',
972
        'database values' => array('10'),
643 973
        'database default values' => array('1'),
974
        // Conditionals match against the 'sample values'.
975
        'match conditional values' => array(
976
          'equal' => '10',
977
          'not_equal' => '2.5',
978
          'less_than' => '11.5',
979
          'greater_than' => '1',
980
        ),
981
        'mismatch conditional values' => array(
982
          'equal' => '2.5',
983
          'not_equal' => '10',
984
          'less_than' => '10',
985
          'greater_than' => '11.5',
986
        ),
644 987
      ),
645 988
    );
646 989

  
......
663 1006
     'tnid' => '0',
664 1007
     'translate' => '0',
665 1008
     'title' => 'Test Webform',
666
     'body' => array(LANGUAGE_NONE => array(array('value' => 'Donec placerat. Nullam nibh dolor, blandit sed, fermentum id, imperdiet sit amet, neque. Nam mollis ultrices justo. Sed tempor. Sed vitae tellus. Etiam sem arcu, eleifend sit amet, gravida eget, porta at, wisi. Nam non lacus vitae ipsum viverra pretium. Phasellus massa. Fusce magna sem, gravida in, feugiat ac, molestie eget, wisi. Fusce consectetuer luctus ipsum. Vestibulum nunc. Suspendisse dignissim adipiscing libero. Integer leo. Sed pharetra ligula a dui. Quisque ipsum nibh, ullamcorper eget, pulvinar sed, posuere vitae, nulla. Sed varius nibh ut lacus. Curabitur fringilla. Nunc est ipsum, pretium quis, dapibus sed, varius non, lectus. Proin a quam. Praesent lacinia, eros quis aliquam porttitor, urna lacus volutpat urna, ut fermentum neque mi egestas dolor.'))),
667
     'teaser' => array(LANGUAGE_NONE => array(array('value' => 'Donec placerat. Nullam nibh dolor, blandit sed, fermentum id, imperdiet sit amet, neque. Nam mollis ultrices justo. Sed tempor. Sed vitae tellus. Etiam sem arcu, eleifend sit amet, gravida eget, porta at, wisi. Nam non lacus vitae ipsum viverra pretium. Phasellus massa. Fusce magna sem, gravida in, feugiat ac, molestie eget, wisi. Fusce consectetuer luctus ipsum. Vestibulum nunc. Suspendisse dignissim adipiscing libero. Integer leo. Sed pharetra ligula a dui. Quisque ipsum nibh, ullamcorper eget, pulvinar sed, posuere vitae, nulla. Sed varius nibh ut lacus. Curabitur fringilla.'))),
668 1009
     'log' => '',
669 1010
     'format' => '1',
670 1011
     'webform' => array(
671 1012
        'confirmation' => 'Thanks!',
672
        'confirmation_format' => filter_default_format(),
673
        'redirect_url' => '<confirmation>',
674
        'teaser' => '0',
675
        'allow_draft' => '1',
676
        'submit_text' => '',
677
        'submit_limit' => '-1',
678
        'submit_interval' => '-1',
679
        'submit_notice' => '1',
680
        'roles' => array('1', '2'),
681
        'components' => array(),
682
        'emails' => array(),
683
      ),
1013
      ) + webform_node_defaults(),
684 1014
    );
685 1015

  
686 1016
    $cid = 0;
......
698 1028

  
699 1029
  /**
700 1030
   * Generate a list of all values that would result in a valid submission.
1031
   *
1032
   * @param $input_values
1033
   *   An array of input values keyed by the component form key. If none
1034
   *   are specified, the defaults will be pulled from testWebformComponents().
701 1035
   */
702
  function testWebformPost() {
1036
  function testWebformPost($input_values = NULL) {
703 1037
    $edit = array();
704
    foreach ($this->testWebformComponents() as $key => $component_info) {
705
      if (is_array($component_info['sample values'])) {
706
        foreach ($component_info['sample values'] as $subkey => $value) {
1038

  
1039
    if (empty($input_values)) {
1040
      $input_values = array();
1041
      foreach ($this->testWebformComponents() as $key => $component_info) {
1042
        $input_values[$key] = $component_info['sample values'];
1043
      }
1044
    }
1045

  
1046
    foreach ($input_values as $key => $values) {
1047
      if (is_array($values)) {
1048
        foreach ($values as $subkey => $value) {
707 1049
          $edit["submitted[$key][$subkey]"] = $value;
708 1050
        }
709 1051
      }
710
      elseif ($component_info['sample values'] != NULL) {
711
        $value = $component_info['sample values'];
1052
      elseif ($values != NULL) {
1053
        $value = $values;
712 1054
        // Multiple selects have a funky extra empty bracket in the name.
713 1055
        $extra = $key == 'select_multiple' ? '[]' : '';
714 1056
        $edit["submitted[$key]$extra"] = $value;
......
765 1107
   */
766 1108
  function testWebformCreateNewType() {
767 1109
    // Enable webforms on the page content type.
768
    variable_set('webform_node_types', array('webform', 'page'));
1110
    variable_set('webform_node_webform', TRUE);
1111
    variable_set('webform_node_page', TRUE);
769 1112

  
770 1113
    $settings = array(
771 1114
      'title' => 'Test webform-enabled page',

Formats disponibles : Unified diff