2019-03-16 18:19:25 +03:00
|
|
|
<?php
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2019-08-12 14:20:03 +03:00
|
|
|
declare(strict_types=1);
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2019-03-16 18:19:25 +03:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2019, Thomas Citharel
|
2019-08-12 14:20:03 +03:00
|
|
|
* @copyright Copyright (c) 2019, Georg Ehrke
|
2019-03-16 18:19:25 +03:00
|
|
|
*
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-08-12 14:20:03 +03:00
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
2020-08-24 15:54:25 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2020-12-16 16:54:15 +03:00
|
|
|
* @author Richard Steinmetz <richard@steinmetz.cloud>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Thomas Citharel <nextcloud@tcit.fr>
|
2019-03-16 18:19:25 +03:00
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
2019-03-16 18:19:25 +03:00
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2019-03-16 18:19:25 +03:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2019-12-03 21:57:53 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-03-16 18:19:25 +03:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2019-03-16 18:19:25 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2019-03-16 18:19:25 +03:00
|
|
|
namespace OCA\DAV\Tests\unit\CalDAV\Reminder\NotificationProvider;
|
|
|
|
|
|
|
|
use OCA\DAV\CalDAV\Reminder\NotificationProvider\EmailProvider;
|
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\IL10N;
|
|
|
|
use OCP\ILogger;
|
|
|
|
use OCP\IURLGenerator;
|
|
|
|
use OCP\IUser;
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCP\L10N\IFactory as L10NFactory;
|
2019-03-16 18:19:25 +03:00
|
|
|
use OCP\Mail\IEMailTemplate;
|
|
|
|
use OCP\Mail\IMailer;
|
|
|
|
use OCP\Mail\IMessage;
|
2020-06-23 09:45:01 +03:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2019-08-12 14:20:03 +03:00
|
|
|
use Sabre\VObject\Component\VCalendar;
|
2019-03-16 18:19:25 +03:00
|
|
|
|
|
|
|
class EmailProviderTest extends AbstractNotificationProviderTest {
|
2020-04-10 17:54:27 +03:00
|
|
|
public const USER_EMAIL = 'frodo@hobb.it';
|
2019-03-16 18:19:25 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
/** @var ILogger|MockObject */
|
2019-08-12 14:20:03 +03:00
|
|
|
protected $logger;
|
2019-03-16 18:19:25 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
/** @var L10NFactory|MockObject */
|
2019-08-12 14:20:03 +03:00
|
|
|
protected $l10nFactory;
|
2019-03-16 18:19:25 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
/** @var IL10N|MockObject */
|
2019-08-12 14:20:03 +03:00
|
|
|
protected $l10n;
|
2019-03-16 18:19:25 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
/** @var IURLGenerator|MockObject */
|
2019-08-12 14:20:03 +03:00
|
|
|
protected $urlGenerator;
|
2019-03-16 18:19:25 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
/** @var IConfig|MockObject */
|
2019-08-12 14:20:03 +03:00
|
|
|
protected $config;
|
2019-03-16 18:19:25 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
/** @var IMailer|MockObject */
|
2019-03-16 18:19:25 +03:00
|
|
|
private $mailer;
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function setUp(): void {
|
2019-08-12 14:20:03 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->mailer = $this->createMock(IMailer::class);
|
|
|
|
|
|
|
|
$this->provider = new EmailProvider(
|
|
|
|
$this->config,
|
|
|
|
$this->mailer,
|
|
|
|
$this->logger,
|
|
|
|
$this->l10nFactory,
|
|
|
|
$this->urlGenerator
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSendWithoutAttendees():void {
|
2021-01-25 11:02:38 +03:00
|
|
|
list($user1, $user2, $user3, , $user5) = $users = $this->getUsers();
|
2019-08-12 14:20:03 +03:00
|
|
|
|
|
|
|
$enL10N = $this->createMock(IL10N::class);
|
|
|
|
$enL10N->method('t')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
$enL10N->method('l')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
|
|
|
$deL10N = $this->createMock(IL10N::class);
|
|
|
|
$deL10N->method('t')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
$deL10N->method('l')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
$this->l10nFactory
|
|
|
|
->method('getUserLanguage')
|
|
|
|
->willReturnMap([
|
|
|
|
[$user1, 'en'],
|
|
|
|
[$user2, 'de'],
|
|
|
|
[$user3, 'de'],
|
2021-01-25 11:02:38 +03:00
|
|
|
[$user5, 'de'],
|
2020-06-23 09:45:01 +03:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->l10nFactory
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('findLanguage')
|
|
|
|
->willReturn('en');
|
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
$this->l10nFactory
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('languageExists')
|
2020-06-23 09:45:01 +03:00
|
|
|
->willReturnMap([
|
|
|
|
['dav', 'en', true],
|
|
|
|
['dav', 'de', true],
|
|
|
|
]);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
$this->l10nFactory
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('get')
|
2020-06-23 09:45:01 +03:00
|
|
|
->willReturnMap([
|
|
|
|
['dav', 'en', null, $enL10N],
|
|
|
|
['dav', 'de', null, $deL10N],
|
|
|
|
]);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
|
|
|
$template1 = $this->getTemplateMock();
|
|
|
|
$message11 = $this->getMessageMock('uid1@example.com', $template1);
|
|
|
|
$template2 = $this->getTemplateMock();
|
|
|
|
$message21 = $this->getMessageMock('uid2@example.com', $template2);
|
|
|
|
$message22 = $this->getMessageMock('uid3@example.com', $template2);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(0))
|
|
|
|
->method('createEMailTemplate')
|
|
|
|
->with('dav.calendarReminder')
|
|
|
|
->willReturn($template1);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(1))
|
2021-01-25 11:02:38 +03:00
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('uid1@example.com')
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(2))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message11);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(3))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message11)
|
|
|
|
->willReturn([]);
|
|
|
|
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(4))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createEMailTemplate')
|
|
|
|
->with('dav.calendarReminder')
|
|
|
|
->willReturn($template2);
|
|
|
|
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(5))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('uid2@example.com')
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(6))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message21);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(7))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message21)
|
|
|
|
->willReturn([]);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(8))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('uid3@example.com')
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(9))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message22);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(10))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message22)
|
|
|
|
->willReturn([]);
|
|
|
|
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(11))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('invalid')
|
|
|
|
->willReturn(false);
|
|
|
|
|
2019-08-12 14:20:03 +03:00
|
|
|
$this->setupURLGeneratorMock(2);
|
|
|
|
|
|
|
|
$vcalendar = $this->getNoAttendeeVCalendar();
|
|
|
|
$this->provider->send($vcalendar->VEVENT, $this->calendarDisplayName, $users);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSendWithAttendees(): void {
|
2021-01-25 11:02:38 +03:00
|
|
|
list($user1, $user2, $user3, , $user5) = $users = $this->getUsers();
|
2019-08-12 14:20:03 +03:00
|
|
|
|
|
|
|
$enL10N = $this->createMock(IL10N::class);
|
|
|
|
$enL10N->method('t')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
$enL10N->method('l')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
|
|
|
$deL10N = $this->createMock(IL10N::class);
|
|
|
|
$deL10N->method('t')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
$deL10N->method('l')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnArgument(0);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
$this->l10nFactory
|
|
|
|
->method('getUserLanguage')
|
|
|
|
->willReturnMap([
|
|
|
|
[$user1, 'en'],
|
|
|
|
[$user2, 'de'],
|
|
|
|
[$user3, 'de'],
|
2021-01-25 11:02:38 +03:00
|
|
|
[$user5, 'de'],
|
2020-06-23 09:45:01 +03:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->l10nFactory
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('findLanguage')
|
|
|
|
->willReturn('en');
|
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
$this->l10nFactory
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('languageExists')
|
2020-06-23 09:45:01 +03:00
|
|
|
->willReturnMap([
|
|
|
|
['dav', 'en', true],
|
|
|
|
['dav', 'de', true],
|
|
|
|
]);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
2020-06-23 09:45:01 +03:00
|
|
|
$this->l10nFactory
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('get')
|
2020-06-23 09:45:01 +03:00
|
|
|
->willReturnMap([
|
|
|
|
['dav', 'en', null, $enL10N],
|
|
|
|
['dav', 'de', null, $deL10N],
|
|
|
|
]);
|
2019-08-12 14:20:03 +03:00
|
|
|
|
|
|
|
$template1 = $this->getTemplateMock();
|
|
|
|
$message11 = $this->getMessageMock('foo1@example.org', $template1);
|
|
|
|
$message12 = $this->getMessageMock('uid2@example.com', $template1);
|
|
|
|
$message13 = $this->getMessageMock('uid3@example.com', $template1);
|
|
|
|
$template2 = $this->getTemplateMock();
|
|
|
|
$message21 = $this->getMessageMock('foo3@example.org', $template2);
|
|
|
|
$message22 = $this->getMessageMock('foo4@example.org', $template2);
|
|
|
|
$message23 = $this->getMessageMock('uid1@example.com', $template2);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(0))
|
|
|
|
->method('createEMailTemplate')
|
|
|
|
->with('dav.calendarReminder')
|
|
|
|
->willReturn($template1);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(1))
|
2021-01-25 11:02:38 +03:00
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('foo1@example.org')
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(2))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message11);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(3))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message11)
|
|
|
|
->willReturn([]);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(4))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('uid2@example.com')
|
|
|
|
->willReturn(true);
|
|
|
|
$this->mailer->expects($this->at(5))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message12);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(6))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message12)
|
|
|
|
->willReturn([]);
|
2021-01-25 11:02:38 +03:00
|
|
|
|
|
|
|
$this->mailer->expects($this->at(7))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('uid3@example.com')
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(8))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message13);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(9))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message13)
|
|
|
|
->willReturn([]);
|
|
|
|
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(10))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('invalid')
|
|
|
|
->willReturn(false);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(11))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createEMailTemplate')
|
|
|
|
->with('dav.calendarReminder')
|
|
|
|
->willReturn($template2);
|
|
|
|
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(12))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('foo3@example.org')
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
$this->mailer->expects($this->at(13))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message21);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(14))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message21)
|
|
|
|
->willReturn([]);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(15))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('foo4@example.org')
|
|
|
|
->willReturn(true);
|
|
|
|
$this->mailer->expects($this->at(16))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message22);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(17))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message22)
|
|
|
|
->willReturn([]);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(18))
|
|
|
|
->method('validateMailAddress')
|
|
|
|
->with('uid1@example.com')
|
|
|
|
->willReturn(true);
|
|
|
|
$this->mailer->expects($this->at(19))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('createMessage')
|
|
|
|
->with()
|
|
|
|
->willReturn($message23);
|
2021-01-25 11:02:38 +03:00
|
|
|
$this->mailer->expects($this->at(20))
|
2019-08-12 14:20:03 +03:00
|
|
|
->method('send')
|
|
|
|
->with($message23)
|
|
|
|
->willReturn([]);
|
|
|
|
|
|
|
|
$this->setupURLGeneratorMock(2);
|
|
|
|
|
|
|
|
$vcalendar = $this->getAttendeeVCalendar();
|
|
|
|
$this->provider->send($vcalendar->VEVENT, $this->calendarDisplayName, $users);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return IEMailTemplate
|
|
|
|
*/
|
|
|
|
private function getTemplateMock():IEMailTemplate {
|
|
|
|
$template = $this->createMock(IEMailTemplate::class);
|
|
|
|
|
|
|
|
$template->expects($this->at(0))
|
|
|
|
->method('addHeader')
|
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
$template->expects($this->at(1))
|
2019-03-16 18:19:25 +03:00
|
|
|
->method('setSubject')
|
2019-08-12 14:20:03 +03:00
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
$template->expects($this->at(2))
|
|
|
|
->method('addHeading')
|
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
$template->expects($this->at(3))
|
|
|
|
->method('addBodyListItem')
|
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
$template->expects($this->at(4))
|
|
|
|
->method('addBodyListItem')
|
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
$template->expects($this->at(5))
|
|
|
|
->method('addBodyListItem')
|
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
$template->expects($this->at(6))
|
|
|
|
->method('addBodyListItem')
|
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
$template->expects($this->at(7))
|
|
|
|
->method('addFooter')
|
|
|
|
->with()
|
|
|
|
->willReturn($template);
|
|
|
|
|
|
|
|
return $template;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 11:02:38 +03:00
|
|
|
* @param string $toMail
|
2019-08-12 14:20:03 +03:00
|
|
|
* @param IEMailTemplate $templateMock
|
2021-01-25 11:02:38 +03:00
|
|
|
* @param array|null $replyTo
|
2019-08-12 14:20:03 +03:00
|
|
|
* @return IMessage
|
|
|
|
*/
|
2020-10-05 16:12:57 +03:00
|
|
|
private function getMessageMock(string $toMail, IEMailTemplate $templateMock, array $replyTo = null):IMessage {
|
2019-08-12 14:20:03 +03:00
|
|
|
$message = $this->createMock(IMessage::class);
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
$message->expects($this->at($i++))
|
|
|
|
->method('setFrom')
|
|
|
|
->with([\OCP\Util::getDefaultEmailAddress('reminders-noreply')])
|
|
|
|
->willReturn($message);
|
|
|
|
|
|
|
|
if ($replyTo) {
|
|
|
|
$message->expects($this->at($i++))
|
|
|
|
->method('setReplyTo')
|
|
|
|
->with($replyTo)
|
|
|
|
->willReturn($message);
|
|
|
|
}
|
|
|
|
|
|
|
|
$message->expects($this->at($i++))
|
|
|
|
->method('setTo')
|
|
|
|
->with([$toMail])
|
|
|
|
->willReturn($message);
|
|
|
|
|
|
|
|
$message->expects($this->at($i++))
|
|
|
|
->method('useTemplate')
|
|
|
|
->with($templateMock)
|
|
|
|
->willReturn($message);
|
|
|
|
|
|
|
|
return $message;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getNoAttendeeVCalendar():VCalendar {
|
|
|
|
$vcalendar = new VCalendar();
|
|
|
|
$vcalendar->add('VEVENT', [
|
|
|
|
'SUMMARY' => 'Fellowship meeting',
|
|
|
|
'DTSTART' => new \DateTime('2017-01-01 00:00:00+00:00'), // 1483228800,
|
|
|
|
'UID' => 'uid1234',
|
|
|
|
'LOCATION' => 'Location 123',
|
|
|
|
'DESCRIPTION' => 'DESCRIPTION 456',
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $vcalendar;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getAttendeeVCalendar():VCalendar {
|
|
|
|
$vcalendar = new VCalendar();
|
|
|
|
$vcalendar->add('VEVENT', [
|
|
|
|
'SUMMARY' => 'Fellowship meeting',
|
|
|
|
'DTSTART' => new \DateTime('2017-01-01 00:00:00+00:00'), // 1483228800,
|
|
|
|
'UID' => 'uid1234',
|
|
|
|
'LOCATION' => 'Location 123',
|
|
|
|
'DESCRIPTION' => 'DESCRIPTION 456',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$vcalendar->VEVENT->add(
|
|
|
|
'ATTENDEE',
|
|
|
|
'mailto:foo1@example.org',
|
|
|
|
[
|
|
|
|
'LANG' => 'de',
|
|
|
|
'PARTSTAT' => 'NEEDS-ACTION',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$vcalendar->VEVENT->add(
|
|
|
|
'ATTENDEE',
|
|
|
|
'mailto:foo2@example.org',
|
|
|
|
[
|
|
|
|
'LANG' => 'de',
|
|
|
|
'PARTSTAT' => 'DECLINED',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$vcalendar->VEVENT->add(
|
|
|
|
'ATTENDEE',
|
|
|
|
'mailto:foo3@example.org',
|
|
|
|
[
|
|
|
|
'LANG' => 'en',
|
|
|
|
'PARTSTAT' => 'CONFIRMED',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$vcalendar->VEVENT->add(
|
|
|
|
'ATTENDEE',
|
|
|
|
'mailto:foo4@example.org'
|
|
|
|
);
|
|
|
|
|
|
|
|
$vcalendar->VEVENT->add(
|
|
|
|
'ATTENDEE',
|
|
|
|
'tomail:foo5@example.org'
|
|
|
|
);
|
|
|
|
|
|
|
|
return $vcalendar;
|
|
|
|
}
|
|
|
|
|
2020-10-05 16:12:57 +03:00
|
|
|
private function setupURLGeneratorMock(int $times = 1):void {
|
2019-08-12 14:20:03 +03:00
|
|
|
for ($i = 0; $i < $times; $i++) {
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i))
|
|
|
|
->method('imagePath')
|
2020-11-05 20:18:40 +03:00
|
|
|
->with('core', 'actions/info.png')
|
2019-08-12 14:20:03 +03:00
|
|
|
->willReturn('imagePath1');
|
|
|
|
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i + 1))
|
|
|
|
->method('getAbsoluteURL')
|
|
|
|
->with('imagePath1')
|
|
|
|
->willReturn('AbsURL1');
|
|
|
|
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i + 2))
|
|
|
|
->method('imagePath')
|
2020-11-05 20:18:40 +03:00
|
|
|
->with('core', 'places/calendar.png')
|
2019-08-12 14:20:03 +03:00
|
|
|
->willReturn('imagePath2');
|
|
|
|
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i + 3))
|
|
|
|
->method('getAbsoluteURL')
|
|
|
|
->with('imagePath2')
|
|
|
|
->willReturn('AbsURL2');
|
|
|
|
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i + 4))
|
|
|
|
->method('imagePath')
|
2020-11-05 20:18:40 +03:00
|
|
|
->with('core', 'actions/address.png')
|
2019-08-12 14:20:03 +03:00
|
|
|
->willReturn('imagePath3');
|
|
|
|
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i + 5))
|
|
|
|
->method('getAbsoluteURL')
|
|
|
|
->with('imagePath3')
|
|
|
|
->willReturn('AbsURL3');
|
|
|
|
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i + 6))
|
|
|
|
->method('imagePath')
|
2020-11-05 20:18:40 +03:00
|
|
|
->with('core', 'actions/more.png')
|
2019-08-12 14:20:03 +03:00
|
|
|
->willReturn('imagePath4');
|
|
|
|
|
|
|
|
$this->urlGenerator
|
|
|
|
->expects($this->at(8 * $i + 7))
|
|
|
|
->method('getAbsoluteURL')
|
|
|
|
->with('imagePath4')
|
|
|
|
->willReturn('AbsURL4');
|
|
|
|
}
|
|
|
|
}
|
2021-01-25 11:02:38 +03:00
|
|
|
|
|
|
|
private function getUsers(): array {
|
|
|
|
$user1 = $this->createMock(IUser::class);
|
|
|
|
$user1->method('getUID')
|
|
|
|
->willReturn('uid1');
|
|
|
|
$user1->method('getEMailAddress')
|
|
|
|
->willReturn('uid1@example.com');
|
|
|
|
$user2 = $this->createMock(IUser::class);
|
|
|
|
$user2->method('getUID')
|
|
|
|
->willReturn('uid2');
|
|
|
|
$user2->method('getEMailAddress')
|
|
|
|
->willReturn('uid2@example.com');
|
|
|
|
$user3 = $this->createMock(IUser::class);
|
|
|
|
$user3->method('getUID')
|
|
|
|
->willReturn('uid3');
|
|
|
|
$user3->method('getEMailAddress')
|
|
|
|
->willReturn('uid3@example.com');
|
|
|
|
$user4 = $this->createMock(IUser::class);
|
|
|
|
$user4->method('getUID')
|
|
|
|
->willReturn('uid4');
|
|
|
|
$user4->method('getEMailAddress')
|
|
|
|
->willReturn(null);
|
|
|
|
$user5 = $this->createMock(IUser::class);
|
|
|
|
$user5->method('getUID')
|
|
|
|
->willReturn('uid5');
|
|
|
|
$user5->method('getEMailAddress')
|
|
|
|
->willReturn('invalid');
|
|
|
|
|
|
|
|
return [$user1, $user2, $user3, $user4, $user5];
|
|
|
|
}
|
2019-03-16 18:19:25 +03:00
|
|
|
}
|