示例#1
0
 public function testSpooledMailing()
 {
     $this->webtestLogin();
     // Start spooling mail
     $mut = new CiviMailUtils($this, TRUE);
     // Add a contact
     $fname = substr(sha1(rand()), 0, 6);
     $lname = substr(sha1(rand()), 0, 6);
     $email = $this->webtestAddContact($fname, $lname, TRUE);
     // Get the contact id of the newly added contact
     $cid = $this->urlArg('cid');
     // Send an email to the added contact
     $this->openCiviPage("activity/email/add", "action=add&reset=1&cid={$cid}&selectedChild=activity&atype=3");
     $this->type('subject', 'test spool');
     $this->fillRichTextField('html_message', 'Unit tests keep children safe.');
     $this->click("_qf_Email_upload");
     // Retrieve an ezc mail object version of the email
     $msg = $mut->getMostRecentEmail('ezc');
     $this->assertNotEmpty($msg, 'Mail message empty or not found.');
     $this->assertEquals($msg->subject, 'test spool');
     // should really walk through the 'to' array, but this is legal according to the docs
     $this->assertContains($email, implode(';', $msg->to), 'Recipient incorrect.');
     $context = new ezcMailPartWalkContext(array(get_class($this), 'mailWalkCallback'));
     $msg->walkParts($context, $msg);
     /*
      *  Now try a regular activity with cc to assignee
      */
     $this->WebtestAddActivity();
     $msg = $mut->getMostRecentEmail('raw');
     $this->assertNotEmpty($msg, 'Mail message empty or not found.');
     $this->assertContains('Subject: This is subject of test activity', $msg, 'Subject of email is wrong.');
     $mut->stop();
 }
示例#2
0
 public function testStandaloneActivityAdd()
 {
     $this->webtestLogin();
     $this->openCiviPage("admin/setting/preferences/display", "reset=1", "name=activity_assignee_notification_ics");
     // Notify assignees should be checked by default, so we just need to click the ical setting which is off by default.
     $this->check("name=activity_assignee_notification_ics");
     $this->click("_qf_Display_next");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     // Start spooling emails
     $mailer = new CiviMailUtils($this, TRUE);
     self::$foundIt = FALSE;
     $firstName1 = substr(sha1(rand()), 0, 7);
     $this->webtestAddContact("{$firstName1}", "Anderson", $firstName1 . "@anderson.com");
     $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
     $this->select("activity_type_id", "value=1");
     $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
     // Because it tends to cause problems, all uses of sleep() must be justified in comments
     // Sleep should never be used for wait for anything to load from the server
     // Justification for this instance: tokeninput has a slight delay
     sleep(1);
     $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
     $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
     $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
     $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
     $this->clickAt("xpath=//div[@class='select2-result-label']");
     $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "{$firstName1}");
     $subject = "Testing Ical attachment for activity assignee";
     $this->type("subject", $subject);
     $location = 'Some location needs to be put in this field.';
     $this->type("location", $location);
     $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
     $this->select("status_id", "value=1");
     $this->click("_qf_Activity_upload");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->waitForText('crm-notification-container', $subject);
     // check the resulting email
     $mail = $mailer->getMostRecentEmail('ezc');
     $this->assertNotNull($mail, ts('Assignee email not generated or problem locating it.'));
     $this->assertEquals($mail->subject, "{$subject}");
     $context = new ezcMailPartWalkContext(array(get_class($this), 'mailWalkCallback'));
     $mail->walkParts($context, $mail);
     $mailer->stop();
     $this->assertTrue(self::$foundIt, ts('Generated email does not contain an ical attachment.'));
 }