reverted: --- b/src/Tests/ContactTest.php +++ a/src/Tests/ContactTest.php @@ -3,7 +3,6 @@ namespace Drupal\reroute_email\Tests; use Drupal\reroute_email\RerouteEmailTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Test Reroute Email module's ability to reroute mail sent from the Contact module form. @@ -54,7 +53,7 @@ $this->configureRerouteEmail(); // Configure the contact settings to send to $original_destination. + $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $this->originalDestination), t('Save')); - $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $this->originalDestination), $this->t('Save')); // Go to the contact page and send an email. $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test'); @@ -65,7 +64,7 @@ $mails = $this->drupalGetMails(); $mail = end($mails); + $this->assertMail('to', $this->rerouteDestination, t("Email was rerouted to @address", array('@address' => $this->rerouteDestination))); - $this->assertMail('to', $this->rerouteDestination, $this->t("Email was rerouted to @address", array('@address' => $this->rerouteDestination))); // Check if original destination email address is in rerouted email body. $this->assertOriginallyTo($mail['body'], 'Found the correct "Originally to" line in the body'); @@ -77,11 +76,11 @@ $this->configureRerouteEmail("{$this->rerouteDestination}, $additional_destination"); // Configure the contact settings to point to the additional recipient. + $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $additional_destination), t('Save')); - $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $additional_destination), $this->t('Save')); // Go to the contact page and send an email. $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test'); + $this->drupalPostForm("contact", $post, t("Send message")); - $this->drupalPostForm("contact", $post, $this->t("Send message")); $this->assertText($this->confirmation_message); $this->assertMail('to', $additional_destination, 'Email was not rerouted because destination was in whitelist'); @@ -90,23 +89,23 @@ $this->configureRerouteEmail(NULL, FALSE); // Set the contact form to send to original_destination. + $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $this->originalDestination), t('Save')); - $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $this->originalDestination), $this->t('Save')); // Go to the contact page and send an email. $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test'); + $this->drupalPostForm("contact", $post, t("Send message")); - $this->drupalPostForm("contact", $post, $this->t("Send message")); $this->assertText($this->confirmation_message); $mails = $this->drupalGetMails(); $mail = end($mails); // Mail should not be rerouted - should go to $original_destination. $this->assertMail('to', $this->originalDestination, 'Mail not rerouted - sent to original destination.'); + $this->verbose(t("Email 'to' was:
@mail_to", array('@mail_to' => $mail['to']))); - $this->verbose($this->t("Email 'to' was:
@mail_to", array('@mail_to' => $mail['to']))); // Configure to reroute without body injection. $this->configureRerouteEmail(NULL, TRUE, FALSE); // Go to the contact page and send an email. $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test'); + $this->drupalPostForm("contact", $post, t("Send message")); - $this->drupalPostForm("contact", $post, $this->t("Send message")); $this->assertText($this->confirmation_message); $mails = $this->drupalGetMails(); $mail = end($mails); reverted: --- b/src/Tests/TestEmailTest.php +++ a/src/Tests/TestEmailTest.php @@ -3,7 +3,6 @@ namespace Drupal\reroute_email\Tests; use Drupal\reroute_email\RerouteEmailTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Test Reroute Email's form for sending a test email. @@ -26,7 +25,7 @@ // Check Subject field default value. $this->drupalGet("admin/config/development/reroute_email/test"); + $this->assertFieldByName('subject', t("Reroute Email Test"), 'The expected default value was found for the Subject field.'); - $this->assertFieldByName('subject', $this->t("Reroute Email Test"), 'The expected default value was found for the Subject field.'); // Submit the Test Email form to send an email to be rerouted. $post = array( @@ -36,8 +35,8 @@ 'subject' => "Test Reroute Email Test Email Form", 'body' => 'Testing email rerouting and the Test Email form', ); + $this->drupalPostForm("admin/config/development/reroute_email/test", $post, t("Send email")); + $this->assertText(t("Test email submitted for delivery from test form.")); - $this->drupalPostForm("admin/config/development/reroute_email/test", $post, $this->t("Send email")); - $this->assertText($this->t("Test email submitted for delivery from test form.")); $mails = $this->drupalGetMails(); $mail = end($mails); // Check rerouted email to. @@ -54,8 +53,8 @@ $this->assertFalse(strpos($mail['body'], $post['body']) === FALSE, 'Body contains the value submitted through the form'); // Check required To field. + $this->drupalPostForm("admin/config/development/reroute_email/test", array('to' => ''), t("Send email")); + $this->assertText(t("To field is required.")); - $this->drupalPostForm("admin/config/development/reroute_email/test", array('to' => ''), $this->t("Send email")); - $this->assertText($this->t("To field is required.")); // Test form submission with email rerouting and invalid email addresses. $post = array( @@ -63,9 +62,9 @@ 'cc' => "Cc address invalid format", 'bcc' => "Bcc address invalid format", ); + $this->drupalPostForm("admin/config/development/reroute_email/test", $post, t("Send email")); - $this->drupalPostForm("admin/config/development/reroute_email/test", $post, $this->t("Send email")); // Successful submission with email rerouting enabled. + $this->assertText(t("Test email submitted for delivery from test form.")); - $this->assertText($this->t("Test email submitted for delivery from test form.")); $mails = $this->drupalGetMails(); $mail = end($mails); // Check rerouted email to. @@ -83,13 +82,13 @@ $this->configureRerouteEmail(NULL, FALSE); // Submit the test email form again with previously used invalid addresses. + $this->drupalPostForm("admin/config/development/reroute_email/test", $post, t("Send email")); - $this->drupalPostForm("admin/config/development/reroute_email/test", $post, $this->t("Send email")); // Check invalid email addresses are still passed to the mail system. $mails = $this->drupalGetMails(); $mail = end($mails); // Check rerouted email to. $this->assertMail('to', $post['to'], format_string('To email address is correctly set to submitted value: @address.', array('@address' => $post['to']))); + $this->verbose(t('Sent email values:
@test_message', array('@test_message' => var_export($test_message, TRUE)))); - $this->verbose($this->t('Test email message values:
@test_message', array('@test_message' => var_export($test_message, TRUE)))); $mails = $this->drupalGetMails(); $mail = end($mails); @@ -74,7 +73,7 @@ // Check the watchdog entry logged by reroute_email_test_mail_alter. $this->drupalGet('admin/reports/dblog'); + $this->assertRaw(t('A String was detected in the body'), 'Recorded in recent log messages: a String was detected in the body.'); - $this->assertRaw($this->t('A String was detected in the body'), 'Recorded in recent log messages: a String was detected in the body.'); // Test the robustness of the CC and BCC keys in headers. $this->assertTrue($mail['headers']['X-Rerouted-Original-Cc'] == $test_message['params']['headers'][$test_cc_key], format_string('X-Rerouted-Original-Cc is correctly set to @test_cc_address, although Cc header message key provided was: @test_cc_key', array(