aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php')
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php176
1 files changed, 128 insertions, 48 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
index 0137f528355..8e71bfa6edf 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -36,54 +38,22 @@ interface IMailServiceMock extends IMailService, IMailMessageSend {
}
class IMipPluginTest extends TestCase {
-
- /** @var IMessage|MockObject */
- private $mailMessage;
-
- /** @var IMailer|MockObject */
- private $mailer;
-
- /** @var IEMailTemplate|MockObject */
- private $emailTemplate;
-
- /** @var IAttachment|MockObject */
- private $emailAttachment;
-
- /** @var ITimeFactory|MockObject */
- private $timeFactory;
-
- /** @var IAppConfig|MockObject */
- private $config;
-
- /** @var IUserSession|MockObject */
- private $userSession;
-
- /** @var IUser|MockObject */
- private $user;
-
- /** @var IMipPlugin */
- private $plugin;
-
- /** @var IMipService|MockObject */
- private $service;
-
- /** @var Defaults|MockObject */
- private $defaults;
-
- /** @var LoggerInterface|MockObject */
- private $logger;
-
- /** @var EventComparisonService|MockObject */
- private $eventComparisonService;
-
- /** @var IMailManager|MockObject */
- private $mailManager;
-
- /** @var IMailService|IMailMessageSend|MockObject */
- private $mailService;
-
- /** @var IMailMessageNew|MockObject */
- private $mailMessageNew;
+ private IMessage&MockObject $mailMessage;
+ private IMailer&MockObject $mailer;
+ private IEMailTemplate&MockObject $emailTemplate;
+ private IAttachment&MockObject $emailAttachment;
+ private ITimeFactory&MockObject $timeFactory;
+ private IAppConfig&MockObject $config;
+ private IUserSession&MockObject $userSession;
+ private IUser&MockObject $user;
+ private IMipPlugin $plugin;
+ private IMipService&MockObject $service;
+ private Defaults&MockObject $defaults;
+ private LoggerInterface&MockObject $logger;
+ private EventComparisonService&MockObject $eventComparisonService;
+ private IMailManager&MockObject $mailManager;
+ private IMailServiceMock&MockObject $mailService;
+ private IMailMessageNew&MockObject $mailMessageNew;
protected function setUp(): void {
$this->mailMessage = $this->createMock(IMessage::class);
@@ -219,6 +189,10 @@ class IMipPluginTest extends TestCase {
->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);
@@ -322,6 +296,88 @@ class IMipPluginTest extends TestCase {
->with($room)
->willReturn(true);
$this->service->expects(self::never())
+ ->method('isCircle');
+ $this->service->expects(self::never())
+ ->method('buildBodyData');
+ $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::never())
+ ->method('getFrom');
+ $this->service->expects(self::never())
+ ->method('addSubjectAndHeading');
+ $this->service->expects(self::never())
+ ->method('addBulletList');
+ $this->service->expects(self::never())
+ ->method('getAttendeeRsvpOrReqForParticipant');
+ $this->config->expects(self::never())
+ ->method('getValueString');
+ $this->service->expects(self::never())
+ ->method('createInvitationToken');
+ $this->service->expects(self::never())
+ ->method('addResponseButtons');
+ $this->service->expects(self::never())
+ ->method('addMoreOptionsButton');
+ $this->mailer->expects(self::never())
+ ->method('send');
+ $this->plugin->schedule($message);
+ $this->assertEquals('1.0', $message->getScheduleStatus());
+ }
+
+ public function testAttendeeIsCircle(): 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 without (!) Boromir',
+ 'DTSTART' => new \DateTime('2016-01-01 00:00:00')
+ ], []));
+ $newVevent->add('ORGANIZER', 'mailto:gandalf@wiz.ard');
+ $newVevent->add('ATTENDEE', 'mailto:' . 'circle+82utEV1Fle8wvxndZLK5TVAPtxj8IIe@middle.earth', ['RSVP' => 'TRUE', 'CN' => 'The Fellowship', 'CUTYPE' => 'GROUP']);
+ $newVevent->add('ATTENDEE', 'mailto:' . 'boromir@tra.it.or', ['RSVP' => 'TRUE', 'MEMBER' => 'circle+82utEV1Fle8wvxndZLK5TVAPtxj8IIe@middle.earth']);
+ $message->message = $newVCalendar;
+ $message->sender = 'mailto:gandalf@wiz.ard';
+ $message->senderName = 'Mr. Wizard';
+ $message->recipient = 'mailto:' . 'circle+82utEV1Fle8wvxndZLK5TVAPtxj8IIe@middle.earth';
+ $attendees = $newVevent->select('ATTENDEE');
+ $circle = '';
+ foreach ($attendees as $attendee) {
+ if (strcasecmp($attendee->getValue(), $message->recipient) === 0) {
+ $circle = $attendee;
+ }
+ }
+ $this->assertNotEmpty($circle, 'Failed to find attendee belonging to the circle');
+ $this->service->expects(self::once())
+ ->method('getLastOccurrence')
+ ->willReturn(1496912700);
+ $this->mailer->expects(self::once())
+ ->method('validateMailAddress')
+ ->with('circle+82utEV1Fle8wvxndZLK5TVAPtxj8IIe@middle.earth')
+ ->willReturn(true);
+ $this->eventComparisonService->expects(self::once())
+ ->method('findModified')
+ ->willReturn(['new' => [$newVevent], 'old' => null]);
+ $this->service->expects(self::once())
+ ->method('getCurrentAttendee')
+ ->with($message)
+ ->willReturn($circle);
+ $this->service->expects(self::once())
+ ->method('isRoomOrResource')
+ ->with($circle)
+ ->willReturn(false);
+ $this->service->expects(self::once())
+ ->method('isCircle')
+ ->with($circle)
+ ->willReturn(true);
+ $this->service->expects(self::never())
->method('buildBodyData');
$this->user->expects(self::any())
->method('getUID')
@@ -423,6 +479,10 @@ class IMipPluginTest extends TestCase {
->with($atnd)
->willReturn(false);
$this->service->expects(self::once())
+ ->method('isCircle')
+ ->with($atnd)
+ ->willReturn(false);
+ $this->service->expects(self::once())
->method('buildBodyData')
->with($newVevent, null)
->willReturn($data);
@@ -554,6 +614,10 @@ class IMipPluginTest extends TestCase {
->with($atnd)
->willReturn(false);
$this->service->expects(self::once())
+ ->method('isCircle')
+ ->with($atnd)
+ ->willReturn(false);
+ $this->service->expects(self::once())
->method('buildBodyData')
->with($newVevent, null)
->willReturn($data);
@@ -660,6 +724,10 @@ class IMipPluginTest extends TestCase {
->with($attendee)
->willReturn(false);
$this->service->expects(self::once())
+ ->method('isCircle')
+ ->with($attendee)
+ ->willReturn(false);
+ $this->service->expects(self::once())
->method('buildBodyData')
->with($event, null)
->willReturn($data);
@@ -767,6 +835,10 @@ class IMipPluginTest extends TestCase {
->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);
@@ -862,6 +934,10 @@ class IMipPluginTest extends TestCase {
->with($atnd)
->willReturn(false);
$this->service->expects(self::once())
+ ->method('isCircle')
+ ->with($atnd)
+ ->willReturn(false);
+ $this->service->expects(self::once())
->method('buildBodyData')
->with($newVevent, null)
->willReturn($data);
@@ -955,6 +1031,10 @@ class IMipPluginTest extends TestCase {
->with($atnd)
->willReturn(false);
$this->service->expects(self::once())
+ ->method('isCircle')
+ ->with($atnd)
+ ->willReturn(false);
+ $this->service->expects(self::once())
->method('buildBodyData')
->with($newVevent, null)
->willReturn($data);