92
tests/feedback.test
Normal file
92
tests/feedback.test
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for Feedback module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test basic Feedback functionality.
|
||||
*/
|
||||
class FeedbackTestCase extends DrupalWebTestCase {
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Feedback functionality',
|
||||
'description' => 'Tests basic Feedback module functionality.',
|
||||
'group' => 'Feedback',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
// @todo Remove soft-dependency on Block.
|
||||
parent::setUp(array('block', 'feedback'));
|
||||
|
||||
$this->admin_user = $this->drupalCreateUser(array('access feedback form', 'view feedback messages', 'administer feedback'));
|
||||
$this->web_user = $this->drupalCreateUser(array('access feedback form'));
|
||||
$this->drupalLogin($this->web_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a basic feedback message.
|
||||
*/
|
||||
function testFeedbackMessage() {
|
||||
$message = $this->randomString();
|
||||
$edit = array(
|
||||
'message' => $message,
|
||||
);
|
||||
$this->drupalPost('node', $edit, t('Send feedback'));
|
||||
|
||||
// Verify the message was recorded.
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$this->drupalGet('admin/reports/feedback');
|
||||
$this->assertRaw(check_plain($message), t('Message found.'));
|
||||
$this->assertText('node', t('Originating system path found.'));
|
||||
$this->assertLinkByHref(url('node', array('absolute' => TRUE)), 0, t('Originating absolute URL found.'));
|
||||
|
||||
// Verify that we can process the message.
|
||||
$edit = array(
|
||||
'feedback-messages[0][1]' => TRUE,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Submit'));
|
||||
$this->assertFieldByName('feedback-messages[1][1]', 1, t('Processed message found.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test visibility settings.
|
||||
*/
|
||||
function testFeedbackVisibility() {
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$this->drupalGet('user');
|
||||
$this->assertRaw('<span class="feedback-link">' . t('Feedback') . '</span>', t('Feedback form shown.'));
|
||||
$edit = array(
|
||||
'feedback_excluded_paths' => 'user*',
|
||||
);
|
||||
$this->drupalPost('admin/config/user-interface/feedback', $edit, t('Save configuration'));
|
||||
$this->drupalGet('user');
|
||||
$this->assertNoRaw('<span class="feedback-link">' . t('Feedback') . '</span>', t('Feedback form not shown.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test feedback deletion.
|
||||
*/
|
||||
function testFeedbackDelete() {
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$message = $this->randomString();
|
||||
$edit = array(
|
||||
'message' => $message,
|
||||
);
|
||||
$this->drupalPost('node', $edit, t('Send feedback'));
|
||||
|
||||
// Verify a delete link is shown.
|
||||
$this->drupalGet('admin/reports/feedback');
|
||||
$this->assertLinkByHref('admin/reports/feedback/1/delete');
|
||||
|
||||
// Verify deletion.
|
||||
$this->drupalPost('admin/reports/feedback/1/delete', array(), t('Delete'));
|
||||
$this->assertRaw(t('The feedback entry was deleted'), t('Feedback deletion message shown.'));
|
||||
$this->assertNoLinkByHref('admin/reports/feedback/1/delete');
|
||||
$this->assertNoRaw(check_plain($message), t('Message not found.'));
|
||||
}
|
||||
}
|
13
tests/feedback_test.info
Normal file
13
tests/feedback_test.info
Normal file
@@ -0,0 +1,13 @@
|
||||
name = Feedback testing
|
||||
description = Tests Feedback module functionality. Do not enable.
|
||||
core = 7.x
|
||||
package = Testing
|
||||
hidden = TRUE
|
||||
dependencies[] = feedback
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-10-22
|
||||
version = "7.x-2.x-dev"
|
||||
core = "7.x"
|
||||
project = "feedback"
|
||||
datestamp = "1350867277"
|
||||
|
7
tests/feedback_test.install
Normal file
7
tests/feedback_test.install
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation functionality for Feedback testing module.
|
||||
*/
|
||||
|
7
tests/feedback_test.module
Normal file
7
tests/feedback_test.module
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Testing functionality for Feedback module.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user