diff --git a/tests/WebformEmailTestCase.test b/tests/WebformEmailTestCase.test index 7c1bfcc1..ad2e6891 100644 --- a/tests/WebformEmailTestCase.test +++ b/tests/WebformEmailTestCase.test @@ -19,7 +19,7 @@ public static function getInfo() { /** * Test the email delivery basics. */ - public function _testEmailDelivery() { + public function testEmailDelivery() { // Some values to use on the forms. $to_address1 = $this->randomName() . '@example.com'; $to_address2 = $this->randomName() . '@example.com'; @@ -117,10 +117,14 @@ public function _testEmailDelivery() { */ public function testConditionalEmail() { // Some values to use on the forms. - $to_address1 = $this->randomName() . '@example.com'; - $to_address2 = $this->randomName() . '@example.com'; - $cc_address1 = $this->randomName() . '@example.com'; - $cc_address2 = $this->randomName() . '@example.com'; + $to_addresses = array( + 1 => $this->randomName() . '@example.com', + 2 => $this->randomName() . '@example.com', + ); + $cc_addresses = array( + 1 => $this->randomName() . '@example.com', + 2 => $this->randomName() . '@example.com', + ); // Login. $this->drupalLogin($this->webform_users['admin']); @@ -146,14 +150,14 @@ public function testConditionalEmail() { $edit = array( // Set some extra email addresses for some fields, to test conditional // email sending. - 'email_mapping[14][nate@localhost.localhost]' => $to_address1, - 'email_mapping[14][admin@localhost.localhost]' => $to_address2, + 'email_mapping[14][nate@localhost.localhost]' => $to_addresses[1], + 'email_mapping[14][admin@localhost.localhost]' => $to_addresses[2], // Test CC addresses too. 'cc_option' => 'component', 'cc_component' => 14, - 'cc_mapping[14][nate@localhost.localhost]' => $cc_address1, - 'cc_mapping[14][admin@localhost.localhost]' => $cc_address2, + 'cc_mapping[14][nate@localhost.localhost]' => $cc_addresses[1], + 'cc_mapping[14][admin@localhost.localhost]' => $cc_addresses[2], ); $this->drupalPost(NULL, $edit, t('Save e-mail settings')); $this->assertResponse(200); @@ -166,20 +170,13 @@ public function testConditionalEmail() { $this->verbose('
' . print_r($mails, TRUE) . '
'); $this->assertEqual(count($mails), 1); if (count($mails) === 1) { - // One of these will be true, it just isn't possible to tell off-hand - // which one. - if ($mails[0]['to'] == $to_address1) { - $this->assertEqual($mails[0]['to'], $to_address1, 'The email was sent to the first address.'); - } - else { - $this->assertEqual($mails[0]['to'], $to_address2, 'The email was sent to the second address.'); - } - if ($mails[0]['params']['headers']['Cc'] == $cc_address1) { - $this->assertEqual($mails[0]['params']['headers']['Cc'], $cc_address1);// "The email was CC'd to the first address."); - } - else { - $this->assertEqual($mails[0]['params']['headers']['Cc'], $cc_address2);//, "The email was CC'd to the second address."); - } + // Make sure that the emails were sent. + $found = in_array($mails[0]['to'], $to_addresses); + $this->assertTrue($found, 'The email was sent to one of the TO addresses.'); + $found = in_array($mails[0]['params']['headers']['Cc'], $cc_addresses); + $this->assertTrue($found, "The email was CC'd to one of the CC addresses."); + $found = in_array($mails[0]['params']['headers']['Cc'], $to_addresses); + $this->assertFalse($found, "The email was not CC'd to one of the TO addresses."); } }