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