permissions.test 1.9 KB

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