Skip to content
Snippets Groups Projects
Unverified Commit 43147aea authored by Georg Ehrke's avatar Georg Ehrke
Browse files

fancify invitation emails

parent 1bb048d1
No related branches found
No related tags found
No related merge requests found
...@@ -25,10 +25,14 @@ namespace OCA\DAV\CalDAV\Schedule; ...@@ -25,10 +25,14 @@ namespace OCA\DAV\CalDAV\Schedule;
use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory as L10NFactory; use OCP\L10N\IFactory as L10NFactory;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer; use OCP\Mail\IMailer;
use Sabre\CalDAV\Schedule\IMipPlugin as SabreIMipPlugin; use Sabre\CalDAV\Schedule\IMipPlugin as SabreIMipPlugin;
use Sabre\DAV\Xml\Element\Prop;
use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VEvent; use Sabre\VObject\Component\VEvent;
use Sabre\VObject\DateTimeParser; use Sabre\VObject\DateTimeParser;
...@@ -70,6 +74,9 @@ class IMipPlugin extends SabreIMipPlugin { ...@@ -70,6 +74,9 @@ class IMipPlugin extends SabreIMipPlugin {
/** @var L10NFactory */ /** @var L10NFactory */
private $l10nFactory; private $l10nFactory;
/** @var IURLGenerator */
private $urlGenerator;
const MAX_DATE = '2038-01-01'; const MAX_DATE = '2038-01-01';
const METHOD_REQUEST = 'request'; const METHOD_REQUEST = 'request';
...@@ -82,9 +89,10 @@ class IMipPlugin extends SabreIMipPlugin { ...@@ -82,9 +89,10 @@ class IMipPlugin extends SabreIMipPlugin {
* @param ILogger $logger * @param ILogger $logger
* @param ITimeFactory $timeFactory * @param ITimeFactory $timeFactory
* @param L10NFactory $l10nFactory * @param L10NFactory $l10nFactory
* @param IUrlGenerator $urlGenerator
* @param string $userId * @param string $userId
*/ */
public function __construct(IConfig $config, IMailer $mailer, ILogger $logger, ITimeFactory $timeFactory, L10NFactory $l10nFactory, $userId) { public function __construct(IConfig $config, IMailer $mailer, ILogger $logger, ITimeFactory $timeFactory, L10NFactory $l10nFactory, IURLGenerator $urlGenerator, $userId) {
parent::__construct(''); parent::__construct('');
$this->userId = $userId; $this->userId = $userId;
$this->config = $config; $this->config = $config;
...@@ -92,6 +100,7 @@ class IMipPlugin extends SabreIMipPlugin { ...@@ -92,6 +100,7 @@ class IMipPlugin extends SabreIMipPlugin {
$this->logger = $logger; $this->logger = $logger;
$this->timeFactory = $timeFactory; $this->timeFactory = $timeFactory;
$this->l10nFactory = $l10nFactory; $this->l10nFactory = $l10nFactory;
$this->urlGenerator = $urlGenerator;
} }
/** /**
...@@ -147,10 +156,29 @@ class IMipPlugin extends SabreIMipPlugin { ...@@ -147,10 +156,29 @@ class IMipPlugin extends SabreIMipPlugin {
$meetingTitle = $vevent->SUMMARY; $meetingTitle = $vevent->SUMMARY;
$meetingDescription = $vevent->DESCRIPTION; $meetingDescription = $vevent->DESCRIPTION;
$meetingStart = $l10n->l('datetime', $vevent->DTSTART->getDateTime()->getTimestamp()); $start = $vevent->DTSTART;
$meetingEnd = $l10n->l('datetime', $vevent->DTEND->getDateTime()->getTimestamp()); if (isset($vevent->DTEND)) {
$end = $vevent->DTEND;
} elseif (isset($vevent->DURATION)) {
$isFloating = $vevent->DTSTART->isFloating();
$end = clone $vevent->DTSTART;
$endDateTime = $end->getDateTime();
$endDateTime = $endDateTime->add(DateTimeParser::parse($vevent->DURATION->getValue()));
$end->setDateTime($endDateTime, $isFloating);
} elseif (!$vevent->DTSTART->hasTime()) {
$isFloating = $vevent->DTSTART->isFloating();
$end = clone $vevent->DTSTART;
$endDateTime = $end->getDateTime();
$endDateTime = $endDateTime->modify('+1 day');
$end->setDateTime($endDateTime, $isFloating);
} else {
$end = clone $vevent->DTSTART;
}
$meetingWhen = $this->generateWhenString($l10n, $start, $end);
$meetingUrl = $vevent->URL; $meetingUrl = $vevent->URL;
$meetingLocation = $vevent->LOCATION;
$defaultVal = '--'; $defaultVal = '--';
...@@ -169,42 +197,22 @@ class IMipPlugin extends SabreIMipPlugin { ...@@ -169,42 +197,22 @@ class IMipPlugin extends SabreIMipPlugin {
'invitee_name' => (string)$meetingInviteeName ?: $defaultVal, 'invitee_name' => (string)$meetingInviteeName ?: $defaultVal,
'meeting_title' => (string)$meetingTitle ?: $defaultVal, 'meeting_title' => (string)$meetingTitle ?: $defaultVal,
'meeting_description' => (string)$meetingDescription ?: $defaultVal, 'meeting_description' => (string)$meetingDescription ?: $defaultVal,
'meeting_start' => (string)$meetingStart,
'meeting_end' => (string)$meetingEnd,
'meeting_url' => (string)$meetingUrl ?: $defaultVal, 'meeting_url' => (string)$meetingUrl ?: $defaultVal,
); );
$message = $this->mailer->createMessage() $message = $this->mailer->createMessage()
->setReplyTo([$sender => $senderName]) ->setReplyTo([$sender => $senderName])
->setTo([$recipient => $recipientName]) ->setTo([$recipient => $recipientName]);
;
$template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data); $template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data);
$template->addHeader(); $template->addHeader();
if ($method === self::METHOD_CANCEL) { $this->addSubjectAndHeading($template, $l10n, $method, $summary,
$template->setSubject('Cancelled: ' . $summary); $meetingAttendeeName, $meetingInviteeName);
$template->addHeading($l10n->t('Event canceled'), $l10n->t('Hello %s,', [$data['attendee_name']])); $this->addBulletList($template, $l10n, $meetingWhen, $meetingLocation,
$template->addBodyText($l10n->t('The meeting with %s was canceled.', [$data['invitee_name']])); $meetingDescription, $meetingUrl);
} else if ($method === self::METHOD_REPLY) {
$template->setSubject('Re: ' . $summary);
$template->addHeading($l10n->t('Event updated'), $l10n->t('Hello %s,', [$data['attendee_name']]));
$template->addBodyText($l10n->t('The meeting with %s was updated.', [$data['invitee_name']]));
} else {
$template->setSubject($summary);
$template->addHeading($l10n->t('Event invitation'), $l10n->t('Hello %s,', [$data['attendee_name']]));
$template->addBodyText($l10n->t('%s has invited you to a meeting.', [$data['invitee_name']]));
}
$template->addBodyText($l10n->t('Title: %s', [$data['meeting_title']]));
$template->addBodyText($l10n->t('Description: %s', [$data['meeting_description']]));
$template->addBodyText($l10n->t('Start: %s', [$data['meeting_start']]));
$template->addBodyText($l10n->t('End: %s', [$data['meeting_end']]));
if ($data['meeting_url']) {
$template->addBodyText($l10n->t('URL: %s', [$data['meeting_url']]));
}
$template->addFooter(); $template->addFooter();
$message->useTemplate($template); $message->useTemplate($template);
$attachment = $this->mailer->createAttachment( $attachment = $this->mailer->createAttachment(
...@@ -309,4 +317,142 @@ class IMipPlugin extends SabreIMipPlugin { ...@@ -309,4 +317,142 @@ class IMipPlugin extends SabreIMipPlugin {
return $default; return $default;
} }
/**
* @param IL10N $l10n
* @param Property $dtstart
* @param Property $dtend
*/
private function generateWhenString(IL10N $l10n, Property $dtstart, Property $dtend) {
$isAllDay = $dtstart instanceof Property\ICalendar\Date;
/** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtstart */
/** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtend */
/** @var \DateTimeImmutable $dtstartDt */
$dtstartDt = $dtstart->getDateTime();
/** @var \DateTimeImmutable $dtendDt */
$dtendDt = $dtend->getDateTime();
$diff = $dtstartDt->diff($dtendDt);
$dtstartDt = new \DateTime($dtstartDt->format(\DateTime::ATOM));
$dtendDt = new \DateTime($dtendDt->format(\DateTime::ATOM));
if ($isAllDay) {
// One day event
if ($diff->days === 1) {
return $l10n->l('date', $dtstartDt, ['width' => 'medium']);
}
//event that spans over multiple days
$localeStart = $l10n->l('date', $dtstartDt, ['width' => 'medium']);
$localeEnd = $l10n->l('date', $dtendDt, ['width' => 'medium']);
return $localeStart . ' - ' . $localeEnd;
}
/** @var Property\ICalendar\DateTime $dtstart */
/** @var Property\ICalendar\DateTime $dtend */
$isFloating = $dtstart->isFloating();
$startTimezone = $endTimezone = null;
if (!$isFloating) {
$prop = $dtstart->offsetGet('TZID');
if ($prop instanceof Parameter) {
$startTimezone = $prop->getValue();
}
$prop = $dtend->offsetGet('TZID');
if ($prop instanceof Parameter) {
$endTimezone = $prop->getValue();
}
}
$localeStart = $l10n->l('datetime', $dtstartDt, ['width' => 'medium']);
// always show full date with timezone if timezones are different
if ($startTimezone !== $endTimezone) {
$localeEnd = $l10n->l('datetime', $dtendDt, ['width' => 'medium']);
return $localeStart . ' (' . $startTimezone . ') - ' .
$localeEnd . ' (' . $endTimezone . ')';
}
// show only end time if date is the same
if ($this->isDayEqual($dtstartDt, $dtendDt)) {
$localeEnd = $l10n->l('time', $dtendDt, ['width' => 'medium']);
} else {
$localeEnd = $l10n->l('datetime', $dtendDt, ['width' => 'medium']);
}
return $localeStart . ' - ' . $localeEnd . ' (' . $startTimezone . ')';
}
/**
* @param \DateTime $dtStart
* @param \DateTime $dtEnd
* @return bool
*/
private function isDayEqual(\DateTime $dtStart, \DateTime $dtEnd) {
return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d');
}
/**
* @param IEMailTemplate $template
* @param IL10N $l10n
* @param string $method
* @param string $summary
* @param string $attendeeName
* @param string $inviteeName
*/
private function addSubjectAndHeading(IEMailTemplate $template, IL10N $l10n,
$method, $summary, $attendeeName, $inviteeName) {
if ($method === self::METHOD_CANCEL) {
$template->setSubject('Cancelled: ' . $summary);
$template->addHeading($l10n->t('Invitation canceled'), $l10n->t('Hello %s,', [$attendeeName]));
$template->addBodyText($l10n->t('The meeting »%s« with %s was canceled.', [$summary, $inviteeName]));
} else if ($method === self::METHOD_REPLY) {
$template->setSubject('Re: ' . $summary);
$template->addHeading($l10n->t('Invitation updated'), $l10n->t('Hello %s,', [$attendeeName]));
$template->addBodyText($l10n->t('The meeting »%s« with %s was updated.', [$summary, $inviteeName]));
} else {
$template->setSubject('Invitation: ' . $summary);
$template->addHeading($l10n->t('%s invited you to »%s«', [$inviteeName, $summary]), $l10n->t('Hello %s,', [$attendeeName]));
}
}
/**
* @param IEMailTemplate $template
* @param IL10N $l10n
* @param string $time
* @param string $location
* @param string $description
* @param string $url
*/
private function addBulletList(IEMailTemplate $template, IL10N $l10n, $time, $location, $description, $url) {
$template->addBodyListItem($time, $l10n->t('When:'),
$this->getAbsoluteImagePath('filetypes/text-calendar.svg'));
if ($location) {
$template->addBodyListItem($location, $l10n->t('Where:'),
$this->getAbsoluteImagePath('filetypes/location.svg'));
}
if ($description) {
$template->addBodyListItem((string)$description, $l10n->t('Description:'),
$this->getAbsoluteImagePath('filetypes/text.svg'));
}
if ($url) {
$template->addBodyListItem((string)$url, $l10n->t('Link:'),
$this->getAbsoluteImagePath('filetypes/link.svg'));
}
}
/**
* @param string $path
* @return string
*/
private function getAbsoluteImagePath($path) {
return $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->imagePath('core', $path)
);
}
} }
...@@ -28,7 +28,15 @@ namespace OCA\DAV\Tests\unit\CalDAV\Schedule; ...@@ -28,7 +28,15 @@ namespace OCA\DAV\Tests\unit\CalDAV\Schedule;
use OC\Mail\Mailer; use OC\Mail\Mailer;
use OCA\DAV\CalDAV\Schedule\IMipPlugin; use OCA\DAV\CalDAV\Schedule\IMipPlugin;
use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\Mail\IMessage;
use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\ITip\Message; use Sabre\VObject\ITip\Message;
use Test\TestCase; use Test\TestCase;
...@@ -36,17 +44,31 @@ use Test\TestCase; ...@@ -36,17 +44,31 @@ use Test\TestCase;
class IMipPluginTest extends TestCase { class IMipPluginTest extends TestCase {
public function testDelivery() { public function testDelivery() {
$mailMessage = new \OC\Mail\Message(new \Swift_Message()); $mailMessage = $this->createMock(IMessage::class);
$mailMessage->method('setReplyTo')->willReturn($mailMessage);
$mailMessage->method('setTo')->willReturn($mailMessage);
/** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */ /** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */
$mailer = $this->getMockBuilder(Mailer::class)->disableOriginalConstructor()->getMock(); $mailer = $this->getMockBuilder(IMailer::class)->disableOriginalConstructor()->getMock();
$emailTemplate = $this->createMock(IEMailTemplate::class);
$emailAttachment = $this->createMock(IAttachment::class);
$mailer->method('createEMailTemplate')->willReturn($emailTemplate);
$mailer->method('createMessage')->willReturn($mailMessage); $mailer->method('createMessage')->willReturn($mailMessage);
$mailer->method('createAttachment')->willReturn($emailAttachment);
$mailer->expects($this->once())->method('send'); $mailer->expects($this->once())->method('send');
/** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */ /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */
$logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
$timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock(); $timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock();
$timeFactory->method('getTime')->willReturn(1); $timeFactory->method('getTime')->willReturn(1);
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject $config */
$config = $this->createMock(IConfig::class);
$l10n = $this->createMock(IL10N::class);
/** @var IFactory | \PHPUnit_Framework_MockObject_MockObject $l10nFactory */
$l10nFactory = $this->createMock(IFactory::class);
$l10nFactory->method('get')->willReturn($l10n);
/** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject $urlGenerator */
$urlGenerator = $this->createMock(IURLGenerator::class);
$plugin = new IMipPlugin($mailer, $logger, $timeFactory); $plugin = new IMipPlugin($config, $mailer, $logger, $timeFactory, $l10nFactory, $urlGenerator, 'user123');
$message = new Message(); $message = new Message();
$message->method = 'REQUEST'; $message->method = 'REQUEST';
$message->message = new VCalendar(); $message->message = new VCalendar();
...@@ -59,26 +81,46 @@ class IMipPluginTest extends TestCase { ...@@ -59,26 +81,46 @@ class IMipPluginTest extends TestCase {
$message->sender = 'mailto:gandalf@wiz.ard'; $message->sender = 'mailto:gandalf@wiz.ard';
$message->recipient = 'mailto:frodo@hobb.it'; $message->recipient = 'mailto:frodo@hobb.it';
$emailTemplate->expects($this->once())
->method('setSubject')
->with('Invitation: Fellowship meeting');
$mailMessage->expects($this->once())
->method('setTo')
->with(['frodo@hobb.it' => null]);
$mailMessage->expects($this->once())
->method('setReplyTo')
->with(['gandalf@wiz.ard' => null]);
$plugin->schedule($message); $plugin->schedule($message);
$this->assertEquals('1.1', $message->getScheduleStatus()); $this->assertEquals('1.1', $message->getScheduleStatus());
$this->assertEquals('Fellowship meeting', $mailMessage->getSubject());
$this->assertEquals(['frodo@hobb.it' => null], $mailMessage->getTo());
$this->assertEquals(['gandalf@wiz.ard' => null], $mailMessage->getReplyTo());
$this->assertEquals('text/calendar; charset=UTF-8; method=REQUEST', $mailMessage->getSwiftMessage()->getContentType());
} }
public function testFailedDelivery() { public function testFailedDelivery() {
$mailMessage = new \OC\Mail\Message(new \Swift_Message()); $mailMessage = $this->createMock(IMessage::class);
$mailMessage->method('setReplyTo')->willReturn($mailMessage);
$mailMessage->method('setTo')->willReturn($mailMessage);
/** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */ /** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */
$mailer = $this->getMockBuilder(Mailer::class)->disableOriginalConstructor()->getMock(); $mailer = $this->getMockBuilder(IMailer::class)->disableOriginalConstructor()->getMock();
$emailTemplate = $this->createMock(IEMailTemplate::class);
$emailAttachment = $this->createMock(IAttachment::class);
$mailer->method('createEMailTemplate')->willReturn($emailTemplate);
$mailer->method('createMessage')->willReturn($mailMessage); $mailer->method('createMessage')->willReturn($mailMessage);
$mailer->method('createAttachment')->willReturn($emailAttachment);
$mailer->method('send')->willThrowException(new \Exception()); $mailer->method('send')->willThrowException(new \Exception());
/** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */ /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */
$logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
$timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock(); $timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock();
$timeFactory->method('getTime')->willReturn(1); $timeFactory->method('getTime')->willReturn(1);
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject $config */
$config = $this->createMock(IConfig::class);
$l10n = $this->createMock(IL10N::class);
/** @var IFactory | \PHPUnit_Framework_MockObject_MockObject $l10nFactory */
$l10nFactory = $this->createMock(IFactory::class);
$l10nFactory->method('get')->willReturn($l10n);
/** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject $urlGenerator */
$urlGenerator = $this->createMock(IURLGenerator::class);
$plugin = new IMipPlugin($mailer, $logger, $timeFactory); $plugin = new IMipPlugin($config, $mailer, $logger, $timeFactory, $l10nFactory, $urlGenerator, 'user123');
$message = new Message(); $message = new Message();
$message->method = 'REQUEST'; $message->method = 'REQUEST';
$message->message = new VCalendar(); $message->message = new VCalendar();
...@@ -91,22 +133,34 @@ class IMipPluginTest extends TestCase { ...@@ -91,22 +133,34 @@ class IMipPluginTest extends TestCase {
$message->sender = 'mailto:gandalf@wiz.ard'; $message->sender = 'mailto:gandalf@wiz.ard';
$message->recipient = 'mailto:frodo@hobb.it'; $message->recipient = 'mailto:frodo@hobb.it';
$emailTemplate->expects($this->once())
->method('setSubject')
->with('Invitation: Fellowship meeting');
$mailMessage->expects($this->once())
->method('setTo')
->with(['frodo@hobb.it' => null]);
$mailMessage->expects($this->once())
->method('setReplyTo')
->with(['gandalf@wiz.ard' => null]);
$plugin->schedule($message); $plugin->schedule($message);
$this->assertEquals('5.0', $message->getScheduleStatus()); $this->assertEquals('5.0', $message->getScheduleStatus());
$this->assertEquals('Fellowship meeting', $mailMessage->getSubject());
$this->assertEquals(['frodo@hobb.it' => null], $mailMessage->getTo());
$this->assertEquals(['gandalf@wiz.ard' => null], $mailMessage->getReplyTo());
$this->assertEquals('text/calendar; charset=UTF-8; method=REQUEST', $mailMessage->getSwiftMessage()->getContentType());
} }
/** /**
* @dataProvider dataNoMessageSendForPastEvents * @dataProvider dataNoMessageSendForPastEvents
*/ */
public function testNoMessageSendForPastEvents($veventParams, $expectsMail) { public function testNoMessageSendForPastEvents($veventParams, $expectsMail) {
$mailMessage = new \OC\Mail\Message(new \Swift_Message()); $mailMessage = $this->createMock(IMessage::class);
$mailMessage->method('setReplyTo')->willReturn($mailMessage);
$mailMessage->method('setTo')->willReturn($mailMessage);
/** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */ /** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */
$mailer = $this->getMockBuilder(Mailer::class)->disableOriginalConstructor()->getMock(); $mailer = $this->getMockBuilder(IMailer::class)->disableOriginalConstructor()->getMock();
$emailTemplate = $this->createMock(IEMailTemplate::class);
$emailAttachment = $this->createMock(IAttachment::class);
$mailer->method('createEMailTemplate')->willReturn($emailTemplate);
$mailer->method('createMessage')->willReturn($mailMessage); $mailer->method('createMessage')->willReturn($mailMessage);
$mailer->method('createAttachment')->willReturn($emailAttachment);
if ($expectsMail) { if ($expectsMail) {
$mailer->expects($this->once())->method('send'); $mailer->expects($this->once())->method('send');
} else { } else {
...@@ -116,8 +170,16 @@ class IMipPluginTest extends TestCase { ...@@ -116,8 +170,16 @@ class IMipPluginTest extends TestCase {
$logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
$timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock(); $timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock();
$timeFactory->method('getTime')->willReturn(1496912528); $timeFactory->method('getTime')->willReturn(1496912528);
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject $config */
$config = $this->createMock(IConfig::class);
$l10n = $this->createMock(IL10N::class);
/** @var IFactory | \PHPUnit_Framework_MockObject_MockObject $l10nFactory */
$l10nFactory = $this->createMock(IFactory::class);
$l10nFactory->method('get')->willReturn($l10n);
/** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject $urlGenerator */
$urlGenerator = $this->createMock(IURLGenerator::class);
$plugin = new IMipPlugin($mailer, $logger, $timeFactory); $plugin = new IMipPlugin($config, $mailer, $logger, $timeFactory, $l10nFactory, $urlGenerator, 'user123');
$message = new Message(); $message = new Message();
$message->method = 'REQUEST'; $message->method = 'REQUEST';
$message->message = new VCalendar(); $message->message = new VCalendar();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment