Project

General

Profile

Paste
Download (2.09 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / webform_validation / tests / WebformValidationTestCase.test @ 76bdcd04

1
<?php
2

    
3
/**
4
 * Test Webform Validation module.
5
 */
6
class WebformValidationTestCase extends WebformTestCase {
7

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

    
47
    // Rule creation page.
48
    $this->clickLink('Minimum length');
49
    $this->assertTitle('Add validation | Drupal');
50
    $element = $this->xpath("//input[@id='edit-data'][@name='data'][@type='text']");
51
    $this->assertTrue($element, 'Page contains "edit-data" input.');
52

    
53
    // Rule created.
54
    $values = array(
55
      'rulename' => $this->randomString(),
56
      'rule_components[21]' => TRUE,
57
      'data' => 2,
58
    );
59
    $this->drupalPost(NULL, $values, t('Add rule'));
60
    $this->assertText(htmlspecialchars($values['rulename'], ENT_QUOTES), 'Rule name appears on page.');
61

    
62
    $this->clickLink('Webform Validation Testing 1');
63
    $element = $this->xpath("//textarea[@id='edit-data'][@name='data']");
64
    $this->assertTrue($element, 'Page contains "edit-data" textarea.');
65
  }
66

    
67
}