permissions.test
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* @file
* Webform module permission tests.
*/
include_once(dirname(__FILE__) . '/webform.test');
class WebformPermissionsTestCase extends WebformTestCase {
/**
* Implements getInfo().
*/
public static function getInfo() {
return array(
'name' => t('Webform permissions'),
'description' => t('Create webforms and check editing and access permissions.'),
'group' => t('Webform'),
);
}
/**
* Implements setUp().
*/
function setUp() {
parent::setUp();
}
/**
* Implements tearDown().
*/
function tearDown() {
parent::tearDown();
}
/**
* Create a webform node in which authenticated users have access to submit.
*/
function testWebformSubmitAccess() {
$this->webformReset();
$node = $this->testWebformForm();
$node->webform['roles'] = array(2);
node_save($node);
// Test that the authenticated user is able to access.
$this->drupalLogin($this->webform_users['userAccess']);
$this->drupalGet('node/' . $node->nid);
$this->assertText($node->body[LANGUAGE_NONE][0]['value'], t('Webform node created and accessible to authenticated users at !url', array('!url' => 'node/' . $node->nid)), t('Webform'));
// Confirm that the submission has been created.
$this->drupalPost(NULL, array(), 'Submit');
$this->assertText($node->webform['confirmation'], t('Confirmation message "@confirmation" received.', array('@confirmation' => $node->webform['confirmation'])), t('Webform'));
$this->drupalLogout();
// The anonymous user should not be able to submit.
$this->drupalGet('node/' . $node->nid);
// Note: Should be: You must <a href="!login">login</a> or <a href="!register">register</a> to view this form.
// Something in SimpleTest isn't handling the string correctly.
$this->assertText('to view this form.', t('Anonymous user is not allowed to submit form.'), t('Webform'));
}
/**
* Create webform
*/
}