$this->_assertMail('jsmith', NULL);
$this->_assertMail('pwulf, sclever, jmcblack, rwright', 'cancel');
}
+
+ /**
+ * testInvitationWithAttachment
+ *
+ * @see 0008592: append event file attachments to invitation mail
+ */
+ public function testInvitationWithAttachment()
+ {
+ $event = $this->_getEvent(TRUE);
+ $event->attendee = $this->_getPersonaAttendee('pwulf');
+
+ $tempFileBackend = new Tinebase_TempFile();
+ $tempFile = $tempFileBackend->createTempFile(dirname(dirname(dirname(__FILE__))) . '/Filemanager/files/test.txt');
+ $event->attachments = array(array('tempFile' => array('id' => $tempFile->getId())));
+
+ self::flushMailer();
+ $persistentEvent = $this->_eventController->create($event);
+
+ $messages = self::getMessages();
+
+ $this->assertEquals(1, count($messages));
+ $parts = $messages[0]->getParts();
+ $this->assertEquals(2, count($parts));
+ $fileAttachment = $parts[1];
+ $this->assertEquals('text/plain; name="=?utf-8?Q?tempfile.tmp?="', $fileAttachment->type);
+
+ // @todo assert attachment content (this seems to not work with array mailer, maybe we need a "real" email test here)
+// $content = $fileAttachment->getDecodedContent();
+// $this->assertEquals('test file content', $content);
+ }
/**
* testUpdateEmpty
'attendee' => $this->_getPersonaAttendee('jmcblack'),
));
+ self::flushMailer();
$persistentEvent = $this->_eventController->create($event);
- //$persistentSClever = Calendar_Model_Attender::getAttendee($persistentEvent->attendee, $event->attendee[1]);
+ $this->_assertMail('jmcblack', 'Recurrance rule: Daily', 'body');
$exceptions = new Tinebase_Record_RecordSet('Calendar_Model_Event');
$recurSet = Calendar_Model_Rrule::computeRecurrenceSet($persistentEvent, $exceptions, $from, $until);
$recurSet[5]->last_modified_time = $updatedBaseEvent->last_modified_time;
$recurSet[5]->summary = 'exceptional summary';
$this->_eventController->createRecurException($recurSet[5], FALSE, FALSE); //2012-03-20
+ $this->_assertMail('jmcblack', 'This is an event series exception', 'body');
$this->_assertMail('jmcblack', 'update');
// reschedule instance
*/
public function testParallelAlarmTrigger()
{
+ $this->markTestSkipped('TODO fixme: 0009116: fix Calendar_Controller_EventNotificationsTests::testParallelAlarmTrigger');
+
$this->_testNeedsTransaction();
try {
*
* @see #6800: add message-id to notification mails
*/
- protected function _assertMail($_personas, $_assertString = NULL)
+ protected function _assertMail($_personas, $_assertString = NULL, $_location = 'subject')
{
$messages = self::getMessages();
$this->assertEquals(0, count($mailsForPersona), 'No mail should be send for '. $personaName);
} else {
$this->assertEquals(1, count($mailsForPersona), 'One mail should be send for '. $personaName);
- $subject = $mailsForPersona[0]->getSubject();
- $this->assertTrue(FALSE !== strpos($subject, $_assertString), 'Mail subject for ' . $personaName . ' should contain "' . $_assertString . '" but '. $subject . ' is given');
$this->assertEquals('UTF-8', $mailsForPersona[0]->getCharset());
+ switch ($_location) {
+ case 'subject':
+ $subject = $mailsForPersona[0]->getSubject();
+ $this->assertTrue(FALSE !== strpos($subject, $_assertString), 'Mail subject for ' . $personaName . ' should contain "' . $_assertString . '" but '. $subject . ' is given');
+ break;
+
+ case 'body':
+ $bodyPart = $mailsForPersona[0]->getBodyText(FALSE);
+
+ // so odd!
+ $s = fopen('php://temp','r+');
+ fputs($s, $bodyPart->getContent());
+ rewind($s);
+ $bodyPartStream = new Zend_Mime_Part($s);
+ $bodyPartStream->encoding = $bodyPart->encoding;
+ $bodyText = $bodyPartStream->getDecodedContent();
+
+ $this->assertContains($_assertString, $bodyText);
+ break;
+
+ default:
+ throw new Exception('no such location '. $_location);
+ break;
+ }
+
$headers = $mailsForPersona[0]->getHeaders();
$this->assertTrue(isset($headers['Message-Id']), 'message-id header not found');
$this->assertContains('@' . php_uname('n'), $headers['Message-Id'][0], 'hostname not in message-id');