|
11 | 11 | use OCA\DAV\CalDAV\Schedule\IMipService; |
12 | 12 | use OCP\AppFramework\Utility\ITimeFactory; |
13 | 13 | use OCP\Defaults; |
14 | | -use OCP\IConfig; |
| 14 | +use OCP\IAppConfig; |
15 | 15 | use OCP\IUser; |
16 | 16 | use OCP\IUserSession; |
17 | 17 | use OCP\Mail\IAttachment; |
@@ -52,7 +52,7 @@ class IMipPluginTest extends TestCase { |
52 | 52 | /** @var ITimeFactory|MockObject */ |
53 | 53 | private $timeFactory; |
54 | 54 |
|
55 | | - /** @var IConfig|MockObject */ |
| 55 | + /** @var IAppConfig|MockObject */ |
56 | 56 | private $config; |
57 | 57 |
|
58 | 58 | /** @var IUserSession|MockObject */ |
@@ -105,7 +105,7 @@ protected function setUp(): void { |
105 | 105 | $this->timeFactory = $this->createMock(ITimeFactory::class); |
106 | 106 | $this->timeFactory->method('getTime')->willReturn(1496912528); // 2017-01-01 |
107 | 107 |
|
108 | | - $this->config = $this->createMock(IConfig::class); |
| 108 | + $this->config = $this->createMock(IAppConfig::class); |
109 | 109 |
|
110 | 110 | $this->user = $this->createMock(IUser::class); |
111 | 111 |
|
@@ -243,7 +243,7 @@ public function testParsingSingle(): void { |
243 | 243 | ->method('getAttendeeRsvpOrReqForParticipant') |
244 | 244 | ->willReturn(true); |
245 | 245 | $this->config->expects(self::once()) |
246 | | - ->method('getAppValue') |
| 246 | + ->method('getValueString') |
247 | 247 | ->with('dav', 'invitation_link_recipients', 'yes') |
248 | 248 | ->willReturn('yes'); |
249 | 249 | $this->service->expects(self::once()) |
@@ -341,7 +341,7 @@ public function testAttendeeIsResource(): void { |
341 | 341 | $this->service->expects(self::never()) |
342 | 342 | ->method('getAttendeeRsvpOrReqForParticipant'); |
343 | 343 | $this->config->expects(self::never()) |
344 | | - ->method('getAppValue'); |
| 344 | + ->method('getValueString'); |
345 | 345 | $this->service->expects(self::never()) |
346 | 346 | ->method('createInvitationToken'); |
347 | 347 | $this->service->expects(self::never()) |
@@ -447,7 +447,7 @@ public function testParsingRecurrence(): void { |
447 | 447 | ->method('getAttendeeRsvpOrReqForParticipant') |
448 | 448 | ->willReturn(true); |
449 | 449 | $this->config->expects(self::once()) |
450 | | - ->method('getAppValue') |
| 450 | + ->method('getValueString') |
451 | 451 | ->with('dav', 'invitation_link_recipients', 'yes') |
452 | 452 | ->willReturn('yes'); |
453 | 453 | $this->service->expects(self::once()) |
@@ -578,7 +578,7 @@ public function testFailedDelivery(): void { |
578 | 578 | ->method('getAttendeeRsvpOrReqForParticipant') |
579 | 579 | ->willReturn(true); |
580 | 580 | $this->config->expects(self::once()) |
581 | | - ->method('getAppValue') |
| 581 | + ->method('getValueString') |
582 | 582 | ->with('dav', 'invitation_link_recipients', 'yes') |
583 | 583 | ->willReturn('yes'); |
584 | 584 | $this->service->expects(self::once()) |
@@ -633,7 +633,7 @@ public function testMailProviderSend(): void { |
633 | 633 | ]; |
634 | 634 | // construct system config mock returns |
635 | 635 | $this->config->expects(self::once()) |
636 | | - ->method('getAppValue') |
| 636 | + ->method('getValueString') |
637 | 637 | ->with('dav', 'invitation_link_recipients', 'yes') |
638 | 638 | ->willReturn('yes'); |
639 | 639 | // construct user mock returns |
@@ -708,6 +708,113 @@ public function testMailProviderSend(): void { |
708 | 708 | $this->assertEquals('1.1', $message->getScheduleStatus()); |
709 | 709 | } |
710 | 710 |
|
| 711 | + public function testMailProviderDisabled(): void { |
| 712 | + $message = new Message(); |
| 713 | + $message->method = 'REQUEST'; |
| 714 | + $newVCalendar = new VCalendar(); |
| 715 | + $newVevent = new VEvent($newVCalendar, 'one', array_merge([ |
| 716 | + 'UID' => 'uid-1234', |
| 717 | + 'SEQUENCE' => 1, |
| 718 | + 'SUMMARY' => 'Fellowship meeting without (!) Boromir', |
| 719 | + 'DTSTART' => new \DateTime('2016-01-01 00:00:00') |
| 720 | + ], [])); |
| 721 | + $newVevent-> add( 'ORGANIZER', 'mailto:[email protected]'); |
| 722 | + $newVevent-> add( 'ATTENDEE', 'mailto:' . '[email protected]', [ 'RSVP' => 'TRUE', 'CN' => 'Frodo']); |
| 723 | + $message->message = $newVCalendar; |
| 724 | + $message-> sender = 'mailto:[email protected]'; |
| 725 | + $message->senderName = 'Mr. Wizard'; |
| 726 | + $message-> recipient = 'mailto:' . '[email protected]'; |
| 727 | + // save the old copy in the plugin |
| 728 | + $oldVCalendar = new VCalendar(); |
| 729 | + $oldVEvent = new VEvent($oldVCalendar, 'one', [ |
| 730 | + 'UID' => 'uid-1234', |
| 731 | + 'SEQUENCE' => 0, |
| 732 | + 'SUMMARY' => 'Fellowship meeting', |
| 733 | + 'DTSTART' => new \DateTime('2016-01-01 00:00:00') |
| 734 | + ]); |
| 735 | + $oldVEvent-> add( 'ORGANIZER', 'mailto:[email protected]'); |
| 736 | + $oldVEvent-> add( 'ATTENDEE', 'mailto:' . '[email protected]', [ 'RSVP' => 'TRUE', 'CN' => 'Frodo']); |
| 737 | + $oldVEvent-> add( 'ATTENDEE', 'mailto:' . '[email protected]', [ 'RSVP' => 'TRUE']); |
| 738 | + $oldVCalendar->add($oldVEvent); |
| 739 | + $data = ['invitee_name' => 'Mr. Wizard', |
| 740 | + 'meeting_title' => 'Fellowship meeting without (!) Boromir', |
| 741 | + 'attendee_name' => '[email protected]' |
| 742 | + ]; |
| 743 | + $attendees = $newVevent->select('ATTENDEE'); |
| 744 | + $atnd = ''; |
| 745 | + foreach ($attendees as $attendee) { |
| 746 | + if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { |
| 747 | + $atnd = $attendee; |
| 748 | + } |
| 749 | + } |
| 750 | + $this->plugin->setVCalendar($oldVCalendar); |
| 751 | + $this->service->expects(self::once()) |
| 752 | + ->method('getLastOccurrence') |
| 753 | + ->willReturn(1496912700); |
| 754 | + $this->mailer->expects(self::once()) |
| 755 | + ->method('validateMailAddress') |
| 756 | + |
| 757 | + ->willReturn(true); |
| 758 | + $this->eventComparisonService->expects(self::once()) |
| 759 | + ->method('findModified') |
| 760 | + ->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); |
| 761 | + $this->service->expects(self::once()) |
| 762 | + ->method('getCurrentAttendee') |
| 763 | + ->with($message) |
| 764 | + ->willReturn($atnd); |
| 765 | + $this->service->expects(self::once()) |
| 766 | + ->method('isRoomOrResource') |
| 767 | + ->with($atnd) |
| 768 | + ->willReturn(false); |
| 769 | + $this->service->expects(self::once()) |
| 770 | + ->method('buildBodyData') |
| 771 | + ->with($newVevent, $oldVEvent) |
| 772 | + ->willReturn($data); |
| 773 | + $this->user->expects(self::any()) |
| 774 | + ->method('getUID') |
| 775 | + ->willReturn('user1'); |
| 776 | + $this->user->expects(self::any()) |
| 777 | + ->method('getDisplayName') |
| 778 | + ->willReturn('Mr. Wizard'); |
| 779 | + $this->userSession->expects(self::any()) |
| 780 | + ->method('getUser') |
| 781 | + ->willReturn($this->user); |
| 782 | + $this->service->expects(self::once()) |
| 783 | + ->method('getFrom'); |
| 784 | + $this->service->expects(self::once()) |
| 785 | + ->method('addSubjectAndHeading') |
| 786 | + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', true); |
| 787 | + $this->service->expects(self::once()) |
| 788 | + ->method('addBulletList') |
| 789 | + ->with($this->emailTemplate, $newVevent, $data); |
| 790 | + $this->service->expects(self::once()) |
| 791 | + ->method('getAttendeeRsvpOrReqForParticipant') |
| 792 | + ->willReturn(true); |
| 793 | + $this->config->expects(self::once()) |
| 794 | + ->method('getValueString') |
| 795 | + ->with('dav', 'invitation_link_recipients', 'yes') |
| 796 | + ->willReturn('yes'); |
| 797 | + $this->config->expects(self::once()) |
| 798 | + ->method('getValueBool') |
| 799 | + ->with('core', 'mail_providers_enabled', true) |
| 800 | + ->willReturn(false); |
| 801 | + $this->service->expects(self::once()) |
| 802 | + ->method('createInvitationToken') |
| 803 | + ->with($message, $newVevent, 1496912700) |
| 804 | + ->willReturn('token'); |
| 805 | + $this->service->expects(self::once()) |
| 806 | + ->method('addResponseButtons') |
| 807 | + ->with($this->emailTemplate, 'token'); |
| 808 | + $this->service->expects(self::once()) |
| 809 | + ->method('addMoreOptionsButton') |
| 810 | + ->with($this->emailTemplate, 'token'); |
| 811 | + $this->mailer->expects(self::once()) |
| 812 | + ->method('send') |
| 813 | + ->willReturn([]); |
| 814 | + $this->plugin->schedule($message); |
| 815 | + $this->assertEquals('1.1', $message->getScheduleStatus()); |
| 816 | + } |
| 817 | + |
711 | 818 | public function testNoOldEvent(): void { |
712 | 819 | $message = new Message(); |
713 | 820 | $message->method = 'REQUEST'; |
@@ -779,7 +886,7 @@ public function testNoOldEvent(): void { |
779 | 886 | ->method('getAttendeeRsvpOrReqForParticipant') |
780 | 887 | ->willReturn(true); |
781 | 888 | $this->config->expects(self::once()) |
782 | | - ->method('getAppValue') |
| 889 | + ->method('getValueString') |
783 | 890 | ->with('dav', 'invitation_link_recipients', 'yes') |
784 | 891 | ->willReturn('yes'); |
785 | 892 | $this->service->expects(self::once()) |
@@ -872,7 +979,7 @@ public function testNoButtons(): void { |
872 | 979 | ->method('getAttendeeRsvpOrReqForParticipant') |
873 | 980 | ->willReturn(true); |
874 | 981 | $this->config->expects(self::once()) |
875 | | - ->method('getAppValue') |
| 982 | + ->method('getValueString') |
876 | 983 | ->with('dav', 'invitation_link_recipients', 'yes') |
877 | 984 | ->willReturn('no'); |
878 | 985 | $this->service->expects(self::never()) |
|
0 commit comments