Revision 76bdcd04
Added by Assos Assos almost 6 years ago
drupal7/sites/all/modules/webform_validation/tests/WebformValidationTestCase.test | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 | 3 |
/** |
4 |
* @file |
|
5 | 4 |
* Test Webform Validation module. |
6 | 5 |
*/ |
7 | 6 |
class WebformValidationTestCase extends WebformTestCase { |
7 |
|
|
8 | 8 |
/** |
9 | 9 |
* {@inheritdoc} |
10 | 10 |
*/ |
... | ... | |
20 | 20 |
* {@inheritdoc} |
21 | 21 |
*/ |
22 | 22 |
public function setUp($added_modules = array()) { |
23 |
$modules = array('webform_validation'); |
|
23 |
$modules = array('webform_validation', 'webform_validation_testing');
|
|
24 | 24 |
parent::setUp(array_merge($modules, $added_modules)); |
25 | 25 |
} |
26 | 26 |
|
... | ... | |
31 | 31 |
// Create test Webform. |
32 | 32 |
$node = $this->webformForm(); |
33 | 33 |
|
34 |
// Test access to "Form validation" tab.
|
|
34 |
// Access to "Form validation" tab.
|
|
35 | 35 |
$this->drupalLogin($this->webform_users['userAccess']); |
36 | 36 |
$this->drupalGet('node/' . $node->nid . '/webform/validation'); |
37 | 37 |
$this->assertResponse(403, 'Authenticated user does not have access to "Form validation" tab'); |
38 | 38 |
|
39 |
// Empty validation rules list. |
|
39 | 40 |
$this->drupalLogin($this->webform_users['admin']); |
40 | 41 |
$this->drupalGet('node/' . $node->nid . '/webform/validation'); |
41 | 42 |
$this->assertResponse(200, 'Webform admin user has access to "Form validation" tab'); |
... | ... | |
43 | 44 |
$this->assertText('Add a validation rule'); |
44 | 45 |
$this->assertText('No validation rules available.'); |
45 | 46 |
|
46 |
// Test rule creation.
|
|
47 |
// Rule creation page.
|
|
47 | 48 |
$this->clickLink('Minimum length'); |
48 | 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. |
|
49 | 54 |
$values = array( |
50 | 55 |
'rulename' => $this->randomString(), |
51 | 56 |
'rule_components[21]' => TRUE, |
... | ... | |
53 | 58 |
); |
54 | 59 |
$this->drupalPost(NULL, $values, t('Add rule')); |
55 | 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.'); |
|
56 | 65 |
} |
57 | 66 |
|
58 | 67 |
} |
Also available in: Unified diff
Weekly update of contrib modules