public function testgetContacts()
 {
     $aopCaseUpdates = new AOP_Case_Updates();
     //execute the method and verify that it returns an array
     $result = $aopCaseUpdates->getContacts();
     $this->assertTrue(is_array($result));
 }
 public function sendCaseUpdate(AOP_Case_Updates $caseUpdate)
 {
     global $current_user, $sugar_config;
     $email_template = new EmailTemplate();
     if ($_REQUEST['module'] == 'Import') {
         //Don't send email on import
         return;
     }
     if (!isAOPEnabled()) {
         return;
     }
     if ($caseUpdate->internal) {
         return;
     }
     $signature = array();
     $addDelimiter = true;
     $aop_config = $sugar_config['aop'];
     if ($caseUpdate->assigned_user_id) {
         if ($aop_config['contact_email_template_id']) {
             $email_template = $email_template->retrieve($aop_config['contact_email_template_id']);
             $signature = $current_user->getDefaultSignature();
         }
         if ($email_template) {
             foreach ($caseUpdate->getContacts() as $contact) {
                 $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
                 $emails = array();
                 $emails[] = $contact->emailAddress->getPrimaryAddress($contact);
                 $res = $caseUpdate->sendEmail($emails, $email_template, $signature, $caseUpdate->case_id, $addDelimiter, $contact->id);
             }
         }
     } else {
         $emails = $caseUpdate->getEmailForUser();
         if ($aop_config['user_email_template_id']) {
             $email_template = $email_template->retrieve($aop_config['user_email_template_id']);
         }
         $addDelimiter = false;
         if ($emails && $email_template) {
             $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
             $res = $caseUpdate->sendEmail($emails, $email_template, $signature, $caseUpdate->case_id, $addDelimiter, $caseUpdate->contact_id);
         }
     }
 }