|
|
|
|
@ -130,6 +130,10 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$message->senderName = 'Mr. Wizard'; |
|
|
|
|
$message->recipient = 'mailto:' . 'frodo@hobb.it'; |
|
|
|
|
$message->significantChange = false; |
|
|
|
|
|
|
|
|
|
$this->config->expects(self::never()) |
|
|
|
|
->method('getValueBool'); |
|
|
|
|
|
|
|
|
|
$this->plugin->schedule($message); |
|
|
|
|
$this->assertEquals('1.0', $message->getScheduleStatus()); |
|
|
|
|
} |
|
|
|
|
@ -177,6 +181,12 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::exactly(2)) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['dav', 'caldav_external_attendees_disabled', false, false], |
|
|
|
|
['core', 'mail_providers_enabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->eventComparisonService->expects(self::once()) |
|
|
|
|
->method('findModified') |
|
|
|
|
->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); |
|
|
|
|
@ -280,6 +290,10 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::once()) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->with('dav', 'caldav_external_attendees_disabled', false) |
|
|
|
|
->willReturn(false); |
|
|
|
|
$this->eventComparisonService->expects(self::once()) |
|
|
|
|
->method('findModified') |
|
|
|
|
->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); |
|
|
|
|
@ -354,6 +368,10 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::once()) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->with('dav', 'caldav_external_attendees_disabled', false) |
|
|
|
|
->willReturn(false); |
|
|
|
|
$this->eventComparisonService->expects(self::once()) |
|
|
|
|
->method('findModified') |
|
|
|
|
->willReturn(['new' => [$newVevent], 'old' => null]); |
|
|
|
|
@ -455,6 +473,12 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::exactly(2)) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['dav', 'caldav_external_attendees_disabled', false, false], |
|
|
|
|
['core', 'mail_providers_enabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->eventComparisonService->expects(self::once()) |
|
|
|
|
->method('findModified') |
|
|
|
|
->willReturn(['old' => [] ,'new' => [$newVevent]]); |
|
|
|
|
@ -695,6 +719,12 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::exactly(2)) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['dav', 'caldav_external_attendees_disabled', false, false], |
|
|
|
|
['core', 'mail_providers_enabled', true, true], |
|
|
|
|
]); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getCurrentAttendee') |
|
|
|
|
->with($message) |
|
|
|
|
@ -837,10 +867,12 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
->method('getValueString') |
|
|
|
|
->with('dav', 'invitation_link_recipients', 'yes') |
|
|
|
|
->willReturn('yes'); |
|
|
|
|
$this->config->expects(self::once()) |
|
|
|
|
$this->config->expects(self::exactly(2)) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->with('core', 'mail_providers_enabled', true) |
|
|
|
|
->willReturn(false); |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['dav', 'caldav_external_attendees_disabled', false, false], |
|
|
|
|
['core', 'mail_providers_enabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('createInvitationToken') |
|
|
|
|
->with($message, $newVevent, 1496912700) |
|
|
|
|
@ -888,6 +920,12 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::exactly(2)) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['dav', 'caldav_external_attendees_disabled', false, false], |
|
|
|
|
['core', 'mail_providers_enabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->eventComparisonService->expects(self::once()) |
|
|
|
|
->method('findModified') |
|
|
|
|
->with($newVCalendar, null) |
|
|
|
|
@ -981,6 +1019,12 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::exactly(2)) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['dav', 'caldav_external_attendees_disabled', false, false], |
|
|
|
|
['core', 'mail_providers_enabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->eventComparisonService->expects(self::once()) |
|
|
|
|
->method('findModified') |
|
|
|
|
->with($newVCalendar, null) |
|
|
|
|
@ -1040,4 +1084,156 @@ class IMipPluginTest extends TestCase { |
|
|
|
|
$this->plugin->schedule($message); |
|
|
|
|
$this->assertEquals('1.1', $message->getScheduleStatus()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testExternalAttendeesDisabledForExternalUser(): void { |
|
|
|
|
$message = new Message(); |
|
|
|
|
$message->method = 'REQUEST'; |
|
|
|
|
$newVCalendar = new VCalendar(); |
|
|
|
|
$newVevent = new VEvent($newVCalendar, 'one', array_merge([ |
|
|
|
|
'UID' => 'uid-1234', |
|
|
|
|
'SEQUENCE' => 1, |
|
|
|
|
'SUMMARY' => 'Fellowship meeting', |
|
|
|
|
'DTSTART' => new \DateTime('2016-01-01 00:00:00') |
|
|
|
|
], [])); |
|
|
|
|
$newVevent->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); |
|
|
|
|
$newVevent->add('ATTENDEE', 'mailto:external@example.com', ['RSVP' => 'TRUE', 'CN' => 'External User']); |
|
|
|
|
$message->message = $newVCalendar; |
|
|
|
|
$message->sender = 'mailto:gandalf@wiz.ard'; |
|
|
|
|
$message->senderName = 'Mr. Wizard'; |
|
|
|
|
$message->recipient = 'mailto:external@example.com'; |
|
|
|
|
|
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::once()) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->with('dav', 'caldav_external_attendees_disabled', false) |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('isSystemUser') |
|
|
|
|
->with('external@example.com') |
|
|
|
|
->willReturn(false); |
|
|
|
|
$this->eventComparisonService->expects(self::never()) |
|
|
|
|
->method('findModified'); |
|
|
|
|
$this->service->expects(self::never()) |
|
|
|
|
->method('getCurrentAttendee'); |
|
|
|
|
$this->mailer->expects(self::never()) |
|
|
|
|
->method('send'); |
|
|
|
|
|
|
|
|
|
$this->plugin->schedule($message); |
|
|
|
|
$this->assertEquals('5.0', $message->getScheduleStatus()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testExternalAttendeesDisabledForSystemUser(): void { |
|
|
|
|
$message = new Message(); |
|
|
|
|
$message->method = 'REQUEST'; |
|
|
|
|
$newVCalendar = new VCalendar(); |
|
|
|
|
$newVevent = new VEvent($newVCalendar, 'one', array_merge([ |
|
|
|
|
'UID' => 'uid-1234', |
|
|
|
|
'SEQUENCE' => 1, |
|
|
|
|
'SUMMARY' => 'Fellowship meeting', |
|
|
|
|
'DTSTART' => new \DateTime('2016-01-01 00:00:00') |
|
|
|
|
], [])); |
|
|
|
|
$newVevent->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); |
|
|
|
|
$newVevent->add('ATTENDEE', 'mailto:frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); |
|
|
|
|
$message->message = $newVCalendar; |
|
|
|
|
$message->sender = 'mailto:gandalf@wiz.ard'; |
|
|
|
|
$message->senderName = 'Mr. Wizard'; |
|
|
|
|
$message->recipient = 'mailto:frodo@hobb.it'; |
|
|
|
|
|
|
|
|
|
$oldVCalendar = new VCalendar(); |
|
|
|
|
$oldVEvent = new VEvent($oldVCalendar, 'one', [ |
|
|
|
|
'UID' => 'uid-1234', |
|
|
|
|
'SEQUENCE' => 0, |
|
|
|
|
'SUMMARY' => 'Fellowship meeting', |
|
|
|
|
'DTSTART' => new \DateTime('2016-01-01 00:00:00') |
|
|
|
|
]); |
|
|
|
|
$oldVEvent->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); |
|
|
|
|
$oldVEvent->add('ATTENDEE', 'mailto:frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); |
|
|
|
|
$oldVCalendar->add($oldVEvent); |
|
|
|
|
|
|
|
|
|
$data = ['invitee_name' => 'Mr. Wizard', |
|
|
|
|
'meeting_title' => 'Fellowship meeting', |
|
|
|
|
'attendee_name' => 'frodo@hobb.it' |
|
|
|
|
]; |
|
|
|
|
$attendees = $newVevent->select('ATTENDEE'); |
|
|
|
|
$atnd = ''; |
|
|
|
|
foreach ($attendees as $attendee) { |
|
|
|
|
if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { |
|
|
|
|
$atnd = $attendee; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$this->plugin->setVCalendar($oldVCalendar); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getLastOccurrence') |
|
|
|
|
->willReturn(1496912700); |
|
|
|
|
$this->config->expects(self::exactly(2)) |
|
|
|
|
->method('getValueBool') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['dav', 'caldav_external_attendees_disabled', false, true], |
|
|
|
|
['core', 'mail_providers_enabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('isSystemUser') |
|
|
|
|
->with('frodo@hobb.it') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->eventComparisonService->expects(self::once()) |
|
|
|
|
->method('findModified') |
|
|
|
|
->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getCurrentAttendee') |
|
|
|
|
->with($message) |
|
|
|
|
->willReturn($atnd); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('isRoomOrResource') |
|
|
|
|
->with($atnd) |
|
|
|
|
->willReturn(false); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('isCircle') |
|
|
|
|
->with($atnd) |
|
|
|
|
->willReturn(false); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('buildBodyData') |
|
|
|
|
->with($newVevent, $oldVEvent) |
|
|
|
|
->willReturn($data); |
|
|
|
|
$this->user->expects(self::any()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('user1'); |
|
|
|
|
$this->user->expects(self::any()) |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->willReturn('Mr. Wizard'); |
|
|
|
|
$this->userSession->expects(self::any()) |
|
|
|
|
->method('getUser') |
|
|
|
|
->willReturn($this->user); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getFrom'); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('addSubjectAndHeading') |
|
|
|
|
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting', true); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('addBulletList') |
|
|
|
|
->with($this->emailTemplate, $newVevent, $data); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('getAttendeeRsvpOrReqForParticipant') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->config->expects(self::once()) |
|
|
|
|
->method('getValueString') |
|
|
|
|
->with('dav', 'invitation_link_recipients', 'yes') |
|
|
|
|
->willReturn('yes'); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('createInvitationToken') |
|
|
|
|
->with($message, $newVevent, 1496912700) |
|
|
|
|
->willReturn('token'); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('addResponseButtons') |
|
|
|
|
->with($this->emailTemplate, 'token'); |
|
|
|
|
$this->service->expects(self::once()) |
|
|
|
|
->method('addMoreOptionsButton') |
|
|
|
|
->with($this->emailTemplate, 'token'); |
|
|
|
|
$this->mailer->expects(self::once()) |
|
|
|
|
->method('send') |
|
|
|
|
->willReturn([]); |
|
|
|
|
$this->plugin->schedule($message); |
|
|
|
|
$this->assertEquals('1.1', $message->getScheduleStatus()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|