/**
  * testUpdatePreserveAlarmProperties
  * 
  * @see #7430: Calendar sends too much alarms for recurring events
  */
 public function testUpdatePreserveAlarmProperties()
 {
     $alarm30 = new Tinebase_Record_RecordSet('Tinebase_Model_Alarm', array(array('minutes_before' => 30)), TRUE);
     $event = $this->_getEvent();
     $event->dtstart = Tinebase_DateTime::now()->subDay(1)->addMinute(15);
     $event->dtend = clone $event->dtstart;
     $event->dtend->addHour(2);
     $event->rrule = 'FREQ=DAILY;INTERVAL=1;COUNT=3';
     $event->alarms = clone $alarm30;
     $event->organizer = Tinebase_Core::getUser()->contact_id;
     $event = Calendar_Controller_Event::getInstance()->create($event);
     $exceptions = new Tinebase_Record_RecordSet('Calendar_Model_Event');
     $recurSet = Calendar_Model_Rrule::computeRecurrenceSet($event, $exceptions, $event->dtstart, Tinebase_DateTime::now()->addDay(1));
     $exceptionEvent = Calendar_Controller_Event::getInstance()->createRecurException($recurSet->getFirstRecord());
     Tinebase_Alarm::getInstance()->sendPendingAlarms("Tinebase_Event_Async_Minutely");
     Calendar_Controller_EventNotificationsTests::flushMailer();
     $event = $this->_uit->get($event->getId());
     $persistentAlarm = $event->exdate[0]->alarms->getFirstRecord();
     $event->alarms = $event->alarms = clone $alarm30;
     Calendar_Controller_Alarm::setAcknowledgeTime($event->alarms, Tinebase_DateTime::now());
     foreach ($event->exdate as $exdate) {
         $exdate->alarms = clone $alarm30;
     }
     $updatedEvent = $this->_uit->update($event);
     $updatedAlarm = $updatedEvent->exdate[0]->alarms->getFirstRecord();
     $this->assertNotNull($persistentAlarm);
     $diff = $persistentAlarm->diff($updatedAlarm);
     $this->assertTrue($diff->isEmpty(), 'no diff');
     $this->assertTrue(Calendar_Controller_Alarm::getAcknowledgeTime($updatedEvent->alarms->getFirstRecord()) instanceof Tinebase_DateTime, 'ack time missing');
 }
 /**
  * put an exception event created by "remind" option of alarm in iCal
  */
 public function testPutEventExceptionAlarmReminder()
 {
     $event = $this->_createRecurringCalDavEvent();
     $messages = self::getMessages();
     $this->assertEquals(1, count($messages), 'one invitation should be send to sclever');
     $this->_assertMail('sclever', 'invitation');
     // create alarm reminder/snooze exception
     Calendar_Controller_EventNotificationsTests::flushMailer();
     $vcalendar = Calendar_Frontend_WebDAV_EventTest::getVCalendar(dirname(__FILE__) . '/../Import/files/apple_ical_remind_part2.ics');
     $event->put($vcalendar);
     // assert no reschedule mail
     $messages = Calendar_Controller_EventNotificationsTests::getMessages();
     $this->assertEquals(0, count($messages), 'no reschedule mails should be send for implicit exception');
 }
コード例 #3
0
 /**
  * testExternalInvitationRequestProcess
  * - uses felamimail to cache external invitation message
  * 
  * -> external invitation requests are not supported atm
  */
 public function testExternalInvitationRequestProcess()
 {
     $this->_checkIMAPConfig();
     $testConfig = Zend_Registry::get('testConfig');
     $email = $testConfig->email ? $testConfig->email : '*****@*****.**';
     // handle message with fmail (add to cache)
     $message = $this->_emailTestClass->messageTestHelper('calendar_request.eml', NULL, NULL, array('*****@*****.**', $email));
     $complete = Felamimail_Controller_Message::getInstance()->getCompleteMessage($message);
     $iMIP = $complete->preparedParts->getFirstRecord()->preparedData;
     Calendar_Controller_EventNotificationsTests::flushMailer();
     $result = $this->_iMIPFrontend->process($iMIP, Calendar_Model_Attender::STATUS_ACCEPTED);
     $this->_iMIPFrontend->prepareComponent($iMIP);
     $this->_eventIdsToDelete[] = $iMIP->event->getId();
     // assert external organizer
     $this->assertEquals('*****@*****.**', $iMIP->event->organizer->email, 'wrong organizer');
     $this->assertTrue(empty($iMIP->event->organizer->account_id), 'organizer must not have an account');
     // assert attendee
     $this->assertEquals(1, count($iMIP->event->attendee), 'all attendee but curruser must be whiped');
     $this->assertEquals($email, $iMIP->event->attendee->getFirstRecord()->user_id->email, 'wrong attendee mail');
     $this->assertEquals(Tinebase_Core::getUser()->getId(), $iMIP->event->attendee->getFirstRecord()->user_id->account_id, 'wrong attendee');
     $this->assertEquals(Calendar_Model_Attender::STATUS_ACCEPTED, $iMIP->event->attendee->getFirstRecord()->status);
     // assert REPLY message
     $messages = Calendar_Controller_EventNotificationsTests::getMessages();
     $this->assertEquals(1, count($messages), 'only one mails should be send');
     $this->assertTrue(in_array('*****@*****.**', $messages[0]->getRecipients()), 'organizer is not a receipient');
     $this->assertContains('METHOD:REPLY', var_export($messages[0], TRUE), 'method missing');
 }
コード例 #4
0
 /**
  * testExternalInvitationRequestProcess
  */
 public function testExternalInvitationRequestProcess()
 {
     $ics = Calendar_Frontend_WebDAV_EventTest::getVCalendar(dirname(__FILE__) . '/files/invitation_request_external.ics');
     $ics = preg_replace('#DTSTART;VALUE=DATE-TIME;TZID=Europe/Berlin:20111121T130000#', 'DTSTART;VALUE=DATE-TIME;TZID=Europe/Berlin:' . Tinebase_DateTime::now()->addHour(1)->format('Ymd\\THis'), $ics);
     $ics = preg_replace('#DTEND;VALUE=DATE-TIME;TZID=Europe/Berlin:20111121T140000#', 'DTEND;VALUE=DATE-TIME;TZID=Europe/Berlin:' . Tinebase_DateTime::now()->addHour(2)->format('Ymd\\THis'), $ics);
     $iMIP = new Calendar_Model_iMIP(array('id' => Tinebase_Record_Abstract::generateUID(), 'ics' => $ics, 'method' => 'REQUEST', 'originator' => '*****@*****.**'));
     Calendar_Controller_EventNotificationsTests::flushMailer();
     $result = $this->_iMIPFrontendMock->process($iMIP, Calendar_Model_Attender::STATUS_ACCEPTED);
     $this->_iMIPFrontend->prepareComponent($iMIP);
     $this->_eventIdsToDelete[] = $iMIP->event->getId();
     // assert external organizer
     $this->assertEquals('*****@*****.**', $iMIP->event->organizer->email, 'wrong organizer');
     $this->assertTrue(empty($iMIP->event->organizer->account_id), 'organizer must not have an account');
     // assert attendee
     $ownAttendee = Calendar_Model_Attender::getOwnAttender($iMIP->event->attendee);
     $this->assertTrue(!!$ownAttendee, 'own attendee missing');
     $this->assertEquals(5, count($iMIP->event->attendee), 'all attendee must be keeped');
     $this->assertEquals(Calendar_Model_Attender::STATUS_ACCEPTED, $ownAttendee->status, 'must be ACCEPTED');
     // assert no status authkey for external attendee
     foreach ($iMIP->event->attendee as $attendee) {
         if (!$attendee->user_id->account_id) {
             $this->assertFalse(!!$attendee->user_id->status_authkey, 'authkey should be skipped');
         }
     }
     // assert REPLY message to organizer only
     $smtpConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::SMTP);
     if (isset($smtpConfig->from) && !empty($smtpConfig->from)) {
         $messages = Calendar_Controller_EventNotificationsTests::getMessages();
         $this->assertEquals(1, count($messages), 'exactly one mail should be send');
         $this->assertTrue(in_array('*****@*****.**', $messages[0]->getRecipients()), 'organizer is not a receipient');
         $this->assertContains('accepted', $messages[0]->getSubject(), 'wrong subject');
         $this->assertContains('METHOD:REPLY', var_export($messages[0], TRUE), 'method missing');
         $this->assertContains('SEQUENCE:0', var_export($messages[0], TRUE), 'external sequence has not been keepted');
     }
 }
コード例 #5
0
 public static function getMailer()
 {
     if (!self::$_mailer) {
         self::$_mailer = Tinebase_Smtp::getDefaultTransport();
     }
     return self::$_mailer;
 }