/** * testInvitationExternalReply */ public function testInvitationExternalReply() { $email = $email = $this->_getEmailAddress(); $ics = file_get_contents(dirname(__FILE__) . '/files/invitation_reply_external_accepted.ics'); $ics = preg_replace('/unittest@tine20\\.org/', $email, $ics); $iMIP = new Calendar_Model_iMIP(array('id' => Tinebase_Record_Abstract::generateUID(), 'ics' => $ics, 'method' => 'REPLY', 'originator' => '*****@*****.**')); $this->assertEquals(1, $iMIP->getEvent()->seq); $this->assertTrue(!empty($iMIP->getEvent()->last_modified_time)); // force creation of external attendee $externalAttendee = new Calendar_Model_Attender(array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => $iMIP->getEvent()->attendee->getFirstRecord()->user_id, 'status' => Calendar_Model_Attender::STATUS_NEEDSACTION)); // create matching event $event = new Calendar_Model_Event(array('summary' => 'TEST7', 'dtstart' => '2011-11-30 14:00:00', 'dtend' => '2011-11-30 15:00:00', 'description' => 'Early to bed and early to rise, makes a men healthy, wealthy and wise ...', 'attendee' => $this->_getAttendee(), 'organizer' => Tinebase_Core::getUser()->contact_id, 'uid' => 'a8d10369e051094ae9322bd65e8afecac010bfc8')); $event->attendee->addRecord($externalAttendee); $event = Calendar_Controller_Event::getInstance()->create($event); $this->_eventIdsToDelete[] = $event->getId(); // TEST NORMAL REPLY try { $this->_iMIPFrontend->autoProcess($iMIP); } catch (Exception $e) { $this->fail('TEST NORMAL REPLY autoProcess throws Exception: ' . $e); } unset($iMIP->existing_event); $updatedEvent = Calendar_Controller_Event::getInstance()->get($event->getId()); $updatedExternalAttendee = Calendar_Model_Attender::getAttendee($updatedEvent->attendee, $externalAttendee); $this->assertEquals(3, count($updatedEvent->attendee)); $this->assertEquals(Calendar_Model_Attender::STATUS_ACCEPTED, $updatedExternalAttendee->status, 'status not updated'); // TEST ACCEPTABLE NON RECENT REPLY $updatedExternalAttendee->status = Calendar_Model_Attender::STATUS_NEEDSACTION; Calendar_Controller_Event::getInstance()->attenderStatusUpdate($updatedEvent, $updatedExternalAttendee, $updatedExternalAttendee->status_authkey); try { $iMIP->preconditionsChecked = false; $this->_iMIPFrontend->autoProcess($iMIP); } catch (Exception $e) { $this->fail('TEST ACCEPTABLE NON RECENT REPLY autoProcess throws Exception: ' . $e); } unset($iMIP->existing_event); $updatedEvent = Calendar_Controller_Event::getInstance()->get($event->getId()); $updatedExternalAttendee = Calendar_Model_Attender::getAttendee($updatedEvent->attendee, $externalAttendee); $this->assertEquals(3, count($updatedEvent->attendee)); $this->assertEquals(Calendar_Model_Attender::STATUS_ACCEPTED, $updatedExternalAttendee->status, 'status not updated'); // check if attendee are resolved $existingEvent = $this->_iMIPFrontend->getExistingEvent($iMIP); $this->assertTrue($iMIP->existing_event->attendee instanceof Tinebase_Record_RecordSet); $this->assertEquals(3, count($iMIP->existing_event->attendee)); // TEST NON ACCEPTABLE NON RECENT REPLY $iMIP->preconditionsChecked = false; try { $this->_iMIPFrontend->autoProcess($iMIP); $this->fail('autoProcess should throw Calendar_Exception_iMIP'); } catch (Calendar_Exception_iMIP $cei) { $this->assertContains('iMIP preconditions failed: RECENT', $cei->getMessage()); } }
/** * declinecounter precondition * * @param Calendar_Model_iMIP $_iMIP * @return boolean * * @todo implement */ protected function _checkDeclinecounterPreconditions($_iMIP) { $_iMIP->addFailedPrecondition(Calendar_Model_iMIP::PRECONDITION_SUPPORTED, 'processing DECLINECOUNTER is not supported yet'); return FALSE; }