Projet

Général

Profil

Paste
Télécharger (1,67 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / webform_validation / tests / WebformValidationTestCase.test @ 81b16cc2

1
<?php
2

    
3
/**
4
 * @file
5
 * Test Webform Validation module.
6
 */
7
class WebformValidationTestCase extends WebformTestCase {
8
  /**
9
   * {@inheritdoc}
10
   */
11
  public static function getInfo() {
12
    return array(
13
      'name' => t('Webform Validation'),
14
      'description' => t('Test Webform Validation module.'),
15
      'group' => t('Webform'),
16
    );
17
  }
18

    
19
  /**
20
   * {@inheritdoc}
21
   */
22
  public function setUp($added_modules = array()) {
23
    $modules = array('webform_validation');
24
    parent::setUp(array_merge($modules, $added_modules));
25
  }
26

    
27
  /**
28
   * The tests.
29
   */
30
  public function test() {
31
    // Create test Webform.
32
    $node = $this->webformForm();
33

    
34
    // Test access to "Form validation" tab.
35
    $this->drupalLogin($this->webform_users['userAccess']);
36
    $this->drupalGet('node/' . $node->nid . '/webform/validation');
37
    $this->assertResponse(403, 'Authenticated user does not have access to "Form validation" tab');
38

    
39
    $this->drupalLogin($this->webform_users['admin']);
40
    $this->drupalGet('node/' . $node->nid . '/webform/validation');
41
    $this->assertResponse(200, 'Webform admin user has access to "Form validation" tab');
42
    $this->assertTitle('Test Webform | Drupal');
43
    $this->assertText('Add a validation rule');
44
    $this->assertText('No validation rules available.');
45

    
46
    // Test rule creation.
47
    $this->clickLink('Minimum length');
48
    $this->assertTitle('Add validation | Drupal');
49
    $values = array(
50
      'rulename' => $this->randomString(),
51
      'rule_components[21]' => TRUE,
52
      'data' => 2,
53
    );
54
    $this->drupalPost(NULL, $values, t('Add rule'));
55
    $this->assertText(htmlspecialchars($values['rulename'], ENT_QUOTES), 'Rule name appears on page.');
56
  }
57

    
58
}