WebformPermissionsTestCase.test 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Webform module permission tests.
  4. */
  5. class WebformPermissionsTestCase extends WebformTestCase {
  6. /**
  7. * {@inheritdoc}
  8. */
  9. public static function getInfo() {
  10. return array(
  11. 'name' => t('Webform permissions'),
  12. 'description' => t('Create webforms and check editing and access permissions.'),
  13. 'group' => t('Webform'),
  14. );
  15. }
  16. /**
  17. * Create a webform node in which authenticated users have access to submit.
  18. */
  19. public function testWebformSubmitAccess() {
  20. $this->webformReset();
  21. $node = $this->webformForm();
  22. $node->webform['roles'] = array(2);
  23. node_save($node);
  24. // Test that the authenticated user is able to access.
  25. $this->drupalLogin($this->webform_users['userAccess']);
  26. $this->drupalGet('node/' . $node->nid);
  27. $this->assertText($node->title, t('Webform node created and accessible to authenticated users at !url', array('!url' => 'node/' . $node->nid)), t('Webform'));
  28. // Confirm that the submission has been created.
  29. $this->drupalPost(NULL, array(), 'Submit');
  30. $this->assertText($node->webform['confirmation'], t('Confirmation message "@confirmation" received.', array('@confirmation' => $node->webform['confirmation'])), t('Webform'));
  31. $this->drupalLogout();
  32. // The anonymous user should not be able to submit.
  33. $this->drupalGet('node/' . $node->nid);
  34. // Note: Should be: You must <a href="!login">login</a> or
  35. // <a href="!register">register</a> to view this form. Something in
  36. // SimpleTest isn't handling the string correctly.
  37. $this->assertText('to view this form.', t('Anonymous user is not allowed to submit form.'), t('Webform'));
  38. }
  39. }