Skip to content

Commit

Permalink
Next attemp on imip tests
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Nov 7, 2022
1 parent 75d2f4c commit b001804
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions apps/dav/tests/unit/CalDAV/CalendarImplTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testGetKey() {
}

public function testGetDisplayname() {
$this->assertEquals($this->calendarImpl->getDisplayName(),'user readable name 123');
$this->assertEquals($this->calendarImpl->getDisplayName(), 'user readable name 123');
}

public function testGetDisplayColor() {
Expand Down Expand Up @@ -141,17 +141,37 @@ public function testGetPermissionAll() {
}

public function testHandleImipMessage(): void {
$message = <<<EOF
BEGIN:VCALENDAR
PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
METHOD:REPLY
VERSION:2.0
BEGIN:VEVENT
ATTENDEE;PARTSTAT=ACCEPTED:mailto:[email protected]
ORGANIZER:mailto:[email protected]
UID:aUniqueUid
SEQUENCE:2
REQUEST-STATUS:2.0;Success
END:VEVENT
END:VCALENDAR
EOF;

/** @var CustomPrincipalPlugin|MockObject $authPlugin */
$authPlugin = $this->createMock(CustomPrincipalPlugin::class);
$authPlugin->expects(self::once())
->method('setCurrentPrincipal')
->with($this->calendar->getPrincipalURI());

/** @var \Sabre\DAVACL\Plugin|MockObject $schedulingPlugin */
/** @var \Sabre\DAVACL\Plugin|MockObject $aclPlugin*/
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class);
$aclPlugin->expects(self::once())
->method('getPrincipalByUri')
->with('mailto:[email protected]');

/** @var Plugin|MockObject $schedulingPlugin */
$schedulingPlugin = $this->createMock(Plugin::class);
$iTipMessage = $this->getITipMessage($message);
$iTipMessage->recipient = "mailto:[email protected]";
$schedulingPlugin->expects(self::once())
->method('scheduleLocalDelivery')
->with($iTipMessage);

$server = $this->createMock(Server::class);
$server->expects($this->any())
Expand All @@ -162,7 +182,7 @@ public function testHandleImipMessage(): void {
['caldav-schedule', $schedulingPlugin]
]);

$invitationResponseServer = $this->createPartialMock(InvitationResponseServer::class, ['getServer']);
$invitationResponseServer = $this->createPartialMock(InvitationResponseServer::class, ['getServer', 'isExternalAttendee']);
$invitationResponseServer->server = $server;
$invitationResponseServer->expects($this->any())
->method('getServer')
Expand All @@ -179,27 +199,6 @@ public function testHandleImipMessage(): void {
->method('getInvitationResponseServer')
->willReturn($invitationResponseServer);

$message = <<<EOF
BEGIN:VCALENDAR
PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
METHOD:REPLY
VERSION:2.0
BEGIN:VEVENT
ATTENDEE;PARTSTAT=mailto:[email protected]:ACCEPTED
ORGANIZER:mailto:[email protected]
UID:aUniqueUid
SEQUENCE:2
REQUEST-STATUS:2.0;Success
END:VEVENT
END:VCALENDAR
EOF;
/** @var Plugin|MockObject $schedulingPlugin */
$schedulingPlugin = $this->createMock(Plugin::class);
$iTipMessage = $this->getITipMessage($message);
$schedulingPlugin->expects(self::once())
->method('scheduleLocalDelivery')
->with($iTipMessage);

$calendarImpl->handleIMipMessage('filename.ics', $message);
}

Expand Down Expand Up @@ -247,7 +246,7 @@ public function testHandleImipMessageNoCalendarUri(): void {
METHOD:REPLY
VERSION:2.0
BEGIN:VEVENT
ATTENDEE;PARTSTAT=mailto:[email protected]:ACCEPTED
ATTENDEE;PARTSTAT=ACCEPTED:mailto:[email protected]
ORGANIZER:mailto:[email protected]
UID:aUniqueUid
SEQUENCE:2
Expand All @@ -261,7 +260,7 @@ public function testHandleImipMessageNoCalendarUri(): void {
}

private function getITipMessage($calendarData): Message {
$iTipMessage = new Message();
$iTipMessage = new Message();
/** @var VCalendar $vObject */
$vObject = Reader::read($calendarData);
/** @var VEvent $vEvent */
Expand Down

0 comments on commit b001804

Please sign in to comment.