feedback.test 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * @file
  4. * Tests for Feedback module.
  5. */
  6. /**
  7. * Test basic Feedback functionality.
  8. */
  9. class FeedbackTestCase extends DrupalWebTestCase {
  10. protected $profile = 'testing';
  11. public static function getInfo() {
  12. return array(
  13. 'name' => 'Feedback functionality',
  14. 'description' => 'Tests basic Feedback module functionality.',
  15. 'group' => 'Feedback',
  16. );
  17. }
  18. function setUp() {
  19. // @todo Remove soft-dependency on Block.
  20. parent::setUp(array('block', 'feedback'));
  21. $this->admin_user = $this->drupalCreateUser(array('access feedback form', 'view feedback messages', 'administer feedback'));
  22. $this->web_user = $this->drupalCreateUser(array('access feedback form'));
  23. $this->drupalLogin($this->web_user);
  24. }
  25. /**
  26. * Test a basic feedback message.
  27. */
  28. function testFeedbackMessage() {
  29. $message = $this->randomString();
  30. $edit = array(
  31. 'message' => $message,
  32. );
  33. $this->drupalPost('node', $edit, t('Send feedback'));
  34. // Verify the message was recorded.
  35. $this->drupalLogin($this->admin_user);
  36. $this->drupalGet('admin/reports/feedback');
  37. $this->assertRaw(check_plain($message), t('Message found.'));
  38. $this->assertText('node', t('Originating system path found.'));
  39. $this->assertLinkByHref(url('node', array('absolute' => TRUE)), 0, t('Originating absolute URL found.'));
  40. // Verify that we can process the message.
  41. $edit = array(
  42. 'feedback-messages[0][1]' => TRUE,
  43. );
  44. $this->drupalPost(NULL, $edit, t('Submit'));
  45. $this->assertFieldByName('feedback-messages[1][1]', 1, t('Processed message found.'));
  46. }
  47. /**
  48. * Test visibility settings.
  49. */
  50. function testFeedbackVisibility() {
  51. $this->drupalLogin($this->admin_user);
  52. $this->drupalGet('user');
  53. $this->assertRaw('<span class="feedback-link">' . t('Feedback') . '</span>', t('Feedback form shown.'));
  54. $edit = array(
  55. 'feedback_excluded_paths' => 'user*',
  56. );
  57. $this->drupalPost('admin/config/user-interface/feedback', $edit, t('Save configuration'));
  58. $this->drupalGet('user');
  59. $this->assertNoRaw('<span class="feedback-link">' . t('Feedback') . '</span>', t('Feedback form not shown.'));
  60. }
  61. /**
  62. * Test feedback deletion.
  63. */
  64. function testFeedbackDelete() {
  65. $this->drupalLogin($this->admin_user);
  66. $message = $this->randomString();
  67. $edit = array(
  68. 'message' => $message,
  69. );
  70. $this->drupalPost('node', $edit, t('Send feedback'));
  71. // Verify a delete link is shown.
  72. $this->drupalGet('admin/reports/feedback');
  73. $this->assertLinkByHref('admin/reports/feedback/1/delete');
  74. // Verify deletion.
  75. $this->drupalPost('admin/reports/feedback/1/delete', array(), t('Delete'));
  76. $this->assertRaw(t('The feedback entry was deleted'), t('Feedback deletion message shown.'));
  77. $this->assertNoLinkByHref('admin/reports/feedback/1/delete');
  78. $this->assertNoRaw(check_plain($message), t('Message not found.'));
  79. }
  80. }