Projet

Général

Profil

Révision 8916d7ec

Ajouté par Assos Assos il y a plus de 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform_validation/tests/WebformValidationUnitTestCase.test
16 16
    );
17 17
  }
18 18

  
19
  /**
20
   * {@inheritdoc}
21
   */
22
  public function setUp() {
23
    parent::setUp();
24
  }
25

  
26 19
  /**
27 20
   * The tests.
28 21
   */
29 22
  public function test() {
23
    require_once __DIR__ . '/../webform_validation.validators.inc';
30 24

  
31 25
    $validator_name = 'comparison';
32 26
    $items = array(
......
62 56
    $test_value = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule);
63 57
    $value = array('two' => 'Error message.');
64 58
    $this->assertIdentical($test_value, $value, 'Error for failing validation.');
59

  
60
    // Test the 'pattern' validator.
61
    $validator_name = 'pattern';
62
    $items = [];
63
    $components = [];
64
    $rule = [
65
      'data' => 'D-25##|(###) ###-####|@# #@@|@## #@@|@@# #@@|@@## #@@|@#@ #@@|@@#@ #@@|GIR0AA',
66
      'error_message' => 'Invalid value.',
67
    ];
68

  
69
    $items['item_1'] = 'D-25AA';
70
    $test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule);
71
    $this->assertIdentical(count($test), 1, $items['item_1'] . ' fails validation.');
72

  
73
    $items['item_1'] = 'D-2500';
74
    $test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule);
75
    $this->assertIdentical(count($test), 0, $items['item_1'] . ' passes validation.');
76

  
77
    $items['item_1'] = '(123)-456-7890';
78
    $test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule);
79
    $this->assertIdentical(count($test), 1, $items['item_1'] . ' fails validation.');
80

  
81
    $items['item_1'] = '(123) 456-7890';
82
    $test = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule);
83
    $this->assertIdentical(count($test), 0, $items['item_1'] . ' passes validation.');
65 84
  }
66 85

  
67 86
}

Formats disponibles : Unified diff