Project

General

Profile

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

root / drupal7 / sites / all / modules / webform / tests / WebformPermissionsTestCase.test @ 01f36513

1
<?php
2

    
3
/**
4
 * Webform module permission tests.
5
 */
6
class WebformPermissionsTestCase extends WebformTestCase {
7

    
8
  /**
9
   * {@inheritdoc}
10
   */
11
  public static function getInfo() {
12
    return array(
13
      'name' => t('Webform permissions'),
14
      'description' => t('Create webforms and check editing and access permissions.'),
15
      'group' => t('Webform'),
16
    );
17
  }
18

    
19
  /**
20
   * Create a webform node in which authenticated users have access to submit.
21
   */
22
  public function testWebformSubmitAccess() {
23
    $this->webformReset();
24
    $node = $this->webformForm();
25
    $node->webform['roles'] = array(2);
26
    node_save($node);
27

    
28
    // Test that the authenticated user is able to access.
29
    $this->drupalLogin($this->webform_users['userAccess']);
30
    $this->drupalGet('node/' . $node->nid);
31
    $this->assertText($node->title, t('Webform node created and accessible to authenticated users at !url', array('!url' => 'node/' . $node->nid)), t('Webform'));
32

    
33
    // Confirm that the submission has been created.
34
    $this->drupalPost(NULL, array(), 'Submit');
35
    $this->assertText($node->webform['confirmation'], t('Confirmation message "@confirmation" received.', array('@confirmation' => $node->webform['confirmation'])), t('Webform'));
36
    $this->drupalLogout();
37

    
38
    // The anonymous user should not be able to submit.
39
    $this->drupalGet('node/' . $node->nid);
40

    
41
    // Note: Should be: You must <a href="!login">login</a> or <a href="!register">register</a> to view this form.
42
    // Something in SimpleTest isn't handling the string correctly.
43
    $this->assertText('to view this form.', t('Anonymous user is not allowed to submit form.'), t('Webform'));
44
  }
45

    
46
}