CRM-15455 - avoid creating dupes and using deleted contacts in test
authorJamie McClelland <jm@mayfirst.org>
Tue, 14 Oct 2014 17:09:08 +0000 (13:09 -0400)
committerJamie McClelland <jm@mayfirst.org>
Tue, 14 Oct 2014 17:09:08 +0000 (13:09 -0400)
mailings.

----------------------------------------
* CRM-15455: email tests do not properly replace tokens
  https://issues.civicrm.org/jira/browse/CRM-15455

CRM/Mailing/Form/Test.php

index ff9650946c29b94c175e59f8c0d6f2bd89c74adb..677de42610d56d973b4a24275294c9c07007b274 100644 (file)
@@ -289,6 +289,7 @@ WHERE      e.email IN ($emails)
 AND        e.on_hold = 0
 AND        c.is_opt_out = 0
 AND        c.do_not_email = 0
+AND        c.is_deleted = 0
 AND        c.is_deceased = 0
 GROUP BY   e.id
 ORDER BY   e.is_bulkmail DESC, e.is_primary DESC
@@ -306,7 +307,9 @@ ORDER BY   e.is_bulkmail DESC, e.is_primary DESC
 
       $dao->free();
       foreach ($testParams['emails'] as $key => $email) {
-        $email = trim($email);
+        // Email addresses are forced to lower case when saved, so ensure
+        // we have the same case when comparing.
+        $email = trim(strtolower($email));
         $contactId = $emailId = NULL;
         if (array_key_exists($email, $emailDetail)) {
           $emailId = $emailDetail[$email]['email_id'];