upadted feedback module

didn't repatched it for email notification since rules hooks semmes to be added to the module
added the old patch for memory
This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 19:31:48 +02:00
parent c5028bffd3
commit 0cd6215a32
9 changed files with 1481 additions and 1243 deletions

View File

@@ -20,7 +20,8 @@ class FeedbackTestCase extends DrupalWebTestCase {
}
function setUp() {
parent::setUp(array('feedback', 'trigger'));
// @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'));
@@ -48,7 +49,7 @@ class FeedbackTestCase extends DrupalWebTestCase {
$edit = array(
'feedback-messages[0][1]' => TRUE,
);
$this->drupalPost(NULL, $edit, t('Update'));
$this->drupalPost(NULL, $edit, t('Submit'));
$this->assertFieldByName('feedback-messages[1][1]', 1, t('Processed message found.'));
}
@@ -88,72 +89,4 @@ class FeedbackTestCase extends DrupalWebTestCase {
$this->assertNoLinkByHref('admin/reports/feedback/1/delete');
$this->assertNoRaw(check_plain($message), t('Message not found.'));
}
/**
* Test the feedback triggers and actions.
*/
function testFeedbackEmailAction() {
$test_user = $this->drupalCreateUser(array('administer actions', 'administer feedback', 'access feedback form'));
$this->drupalLogin($test_user);
$this->assignFeedbackEmailAction('feedback_insert', $test_user->mail);
// Insert a feedback entry.
$message = $this->randomString();
$edit = array(
'message' => $message,
);
$this->drupalPost('node', $edit, t('Send feedback'));
$this->assertFeedbackEmailTokenReplacement($test_user->mail, $message);
$this->assignFeedbackEmailAction('feedback_update', $test_user->mail);
// Update a feedback entry.
$fid = db_query("SELECT fid FROM {feedback} LIMIT 0,1")->fetchField();
$entry = feedback_load($fid);
feedback_save($entry);
$this->assertFeedbackEmailTokenReplacement($test_user->mail, $entry->message);
}
/**
* Assigns a system_send_email_action to the passed-in trigger.
*
* @param $trigger
* For example, 'user_login'
*/
function assignFeedbackEmailAction($trigger, $mail) {
$form_name = "trigger_{$trigger}_assign_form";
$form_html_id = strtr($form_name, '_', '-');
$edit = array(
'actions_label' => $trigger . "_feedback_send_email_action",
'recipients' => $mail,
'subject' => $this->randomName(),
'message' => '!message',
);
$hash = drupal_hash_base64('feedback_send_email_action');
$this->drupalPost("admin/config/system/actions/configure/$hash", $edit, t('Save'));
$this->assertText(t('The action has been successfully saved.'));
// Now we have to find out the action ID of what we created.
$aid = db_query('SELECT aid FROM {actions} WHERE callback = :callback AND label = :label', array(':callback' => 'feedback_send_email_action', ':label' => $edit['actions_label']))->fetchField();
$edit = array('aid' => drupal_hash_base64($aid));
$this->drupalPost('admin/structure/trigger/feedback', $edit, t('Assign'), array(), array(), $form_html_id);
}
/**
* Asserts correct token replacement for the given trigger and account.
*
* @param $account
* The user account which triggered the action.
* @param $email_depth
* Number of emails to scan, starting with most recent.
*/
function assertFeedbackEmailTokenReplacement($mail, $message, $email_depth = 1) {
$this->verboseEmail($email_depth);
$this->assertMailString('body', $message, $email_depth);
$this->assertMail('to', $mail, t('Mail sent to correct destination'));
}
}
}