2015-12-18 13:56:25 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2017-06-08 12:50:17 +03:00
|
|
|
* @copyright Copyright (c) 2017, Georg Ehrke
|
2016-07-21 17:49:16 +03:00
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author brad2014 <brad2014@users.noreply.github.com>
|
|
|
|
* @author Brad Rubenstein <brad@wbr.tech>
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2017-11-06 22:15:27 +03:00
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author Thomas Citharel <nextcloud@tcit.fr>
|
2015-12-18 13:56:25 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-12-18 13:56:25 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-05-25 17:04:15 +03:00
|
|
|
namespace OCA\DAV\Tests\unit\CalDAV\Schedule;
|
2015-12-18 13:56:25 +03:00
|
|
|
|
|
|
|
use OCA\DAV\CalDAV\Schedule\IMipPlugin;
|
2017-06-08 12:50:17 +03:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
2018-06-19 22:01:14 +03:00
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
2017-11-14 17:01:53 +03:00
|
|
|
use OCP\Defaults;
|
2017-11-02 18:38:16 +03:00
|
|
|
use OCP\IConfig;
|
2018-06-19 22:01:14 +03:00
|
|
|
use OCP\IDBConnection;
|
2017-11-02 18:38:16 +03:00
|
|
|
use OCP\IL10N;
|
2015-12-18 13:56:25 +03:00
|
|
|
use OCP\ILogger;
|
2017-11-02 18:38:16 +03:00
|
|
|
use OCP\IURLGenerator;
|
2019-11-27 13:54:42 +03:00
|
|
|
use OCP\IUser;
|
|
|
|
use OCP\IUserManager;
|
2017-11-02 18:38:16 +03:00
|
|
|
use OCP\L10N\IFactory;
|
|
|
|
use OCP\Mail\IAttachment;
|
|
|
|
use OCP\Mail\IEMailTemplate;
|
|
|
|
use OCP\Mail\IMailer;
|
|
|
|
use OCP\Mail\IMessage;
|
2018-06-19 22:01:14 +03:00
|
|
|
use OCP\Security\ISecureRandom;
|
2020-03-26 20:32:09 +03:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2015-12-18 13:56:25 +03:00
|
|
|
use Sabre\VObject\Component\VCalendar;
|
|
|
|
use Sabre\VObject\ITip\Message;
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class IMipPluginTest extends TestCase {
|
|
|
|
|
2020-03-26 20:32:09 +03:00
|
|
|
/** @var IMessage|MockObject */
|
2020-04-10 15:19:56 +03:00
|
|
|
private $mailMessage;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var IMailer|MockObject */
|
|
|
|
private $mailer;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var IEMailTemplate|MockObject */
|
|
|
|
private $emailTemplate;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var IAttachment|MockObject */
|
|
|
|
private $emailAttachment;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var ITimeFactory|MockObject */
|
|
|
|
private $timeFactory;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var IConfig|MockObject */
|
|
|
|
private $config;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var IUserManager|MockObject */
|
|
|
|
private $userManager;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var IQueryBuilder|MockObject */
|
|
|
|
private $queryBuilder;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
/** @var IMipPlugin */
|
|
|
|
private $plugin;
|
2020-03-26 20:32:09 +03:00
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
protected function setUp(): void {
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->mailMessage = $this->createMock(IMessage::class);
|
|
|
|
$this->mailMessage->method('setFrom')->willReturn($this->mailMessage);
|
|
|
|
$this->mailMessage->method('setReplyTo')->willReturn($this->mailMessage);
|
|
|
|
$this->mailMessage->method('setTo')->willReturn($this->mailMessage);
|
|
|
|
|
|
|
|
$this->mailer = $this->getMockBuilder(IMailer::class)->disableOriginalConstructor()->getMock();
|
|
|
|
$this->mailer->method('createMessage')->willReturn($this->mailMessage);
|
|
|
|
|
|
|
|
$this->emailTemplate = $this->createMock(IEMailTemplate::class);
|
|
|
|
$this->mailer->method('createEMailTemplate')->willReturn($this->emailTemplate);
|
|
|
|
|
|
|
|
$this->emailAttachment = $this->createMock(IAttachment::class);
|
|
|
|
$this->mailer->method('createAttachment')->willReturn($this->emailAttachment);
|
|
|
|
|
2020-03-26 20:32:09 +03:00
|
|
|
/** @var ILogger|MockObject $logger */
|
2017-10-24 16:26:53 +03:00
|
|
|
$logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
|
2019-02-28 04:25:27 +03:00
|
|
|
|
|
|
|
$this->timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock();
|
|
|
|
$this->timeFactory->method('getTime')->willReturn(1496912528); // 2017-01-01
|
|
|
|
|
|
|
|
$this->config = $this->createMock(IConfig::class);
|
|
|
|
|
2019-11-27 13:54:42 +03:00
|
|
|
$this->userManager = $this->createMock(IUserManager::class);
|
|
|
|
|
2017-11-02 18:38:16 +03:00
|
|
|
$l10n = $this->createMock(IL10N::class);
|
2019-11-27 13:54:42 +03:00
|
|
|
$l10n->method('t')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function ($text, $parameters = []) {
|
2019-11-27 13:54:42 +03:00
|
|
|
return vsprintf($text, $parameters);
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2017-11-02 18:38:16 +03:00
|
|
|
$l10nFactory = $this->createMock(IFactory::class);
|
|
|
|
$l10nFactory->method('get')->willReturn($l10n);
|
2019-02-28 04:25:27 +03:00
|
|
|
|
2017-11-02 18:38:16 +03:00
|
|
|
$urlGenerator = $this->createMock(IURLGenerator::class);
|
2019-02-28 04:25:27 +03:00
|
|
|
|
|
|
|
$this->queryBuilder = $this->createMock(IQueryBuilder::class);
|
2018-06-19 22:01:14 +03:00
|
|
|
$db = $this->createMock(IDBConnection::class);
|
2019-02-28 04:25:27 +03:00
|
|
|
$db->method('getQueryBuilder')
|
|
|
|
->with()
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($this->queryBuilder);
|
2015-12-18 13:56:25 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
$random = $this->createMock(ISecureRandom::class);
|
|
|
|
$random->method('generate')
|
2018-06-19 22:01:14 +03:00
|
|
|
->with(60, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('random_token');
|
2018-06-19 22:01:14 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
$defaults = $this->createMock(Defaults::class);
|
|
|
|
$defaults->method('getName')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('Instance Name 123');
|
2019-02-28 04:22:53 +03:00
|
|
|
|
2019-11-27 13:54:42 +03:00
|
|
|
$this->plugin = new IMipPlugin($this->config, $this->mailer, $logger, $this->timeFactory, $l10nFactory, $urlGenerator, $defaults, $random, $db, $this->userManager, 'user123');
|
2019-02-28 04:25:27 +03:00
|
|
|
}
|
2015-12-18 13:56:25 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
public function testDelivery() {
|
|
|
|
$this->config
|
2020-09-02 18:16:24 +03:00
|
|
|
->expects($this->at(1))
|
2019-07-18 02:47:15 +03:00
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'invitation_link_recipients', 'yes')
|
|
|
|
->willReturn('yes');
|
2021-02-11 15:27:02 +03:00
|
|
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
2017-11-02 18:38:16 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
$message = $this->_testMessage();
|
|
|
|
$this->_expectSend();
|
|
|
|
$this->plugin->schedule($message);
|
2015-12-18 13:56:25 +03:00
|
|
|
$this->assertEquals('1.1', $message->getScheduleStatus());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFailedDelivery() {
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->config
|
2020-09-02 18:16:24 +03:00
|
|
|
->expects($this->at(1))
|
2019-07-18 02:47:15 +03:00
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'invitation_link_recipients', 'yes')
|
|
|
|
->willReturn('yes');
|
2021-02-11 15:27:02 +03:00
|
|
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
2019-02-28 04:22:53 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
$message = $this->_testMessage();
|
|
|
|
$this->mailer
|
|
|
|
->method('send')
|
|
|
|
->willThrowException(new \Exception());
|
|
|
|
$this->_expectSend();
|
|
|
|
$this->plugin->schedule($message);
|
2015-12-18 13:56:25 +03:00
|
|
|
$this->assertEquals('5.0', $message->getScheduleStatus());
|
|
|
|
}
|
|
|
|
|
2021-02-11 15:27:02 +03:00
|
|
|
public function testInvalidEmailDelivery() {
|
|
|
|
$this->mailer->method('validateMailAddress')->willReturn(false);
|
|
|
|
|
|
|
|
$message = $this->_testMessage();
|
|
|
|
$this->plugin->schedule($message);
|
|
|
|
$this->assertEquals('5.0', $message->getScheduleStatus());
|
|
|
|
}
|
|
|
|
|
2019-11-27 13:54:42 +03:00
|
|
|
public function testDeliveryWithNoCommonName() {
|
|
|
|
$this->config
|
2020-09-02 18:16:24 +03:00
|
|
|
->expects($this->at(1))
|
2019-11-27 13:54:42 +03:00
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'invitation_link_recipients', 'yes')
|
|
|
|
->willReturn('yes');
|
2021-02-11 15:27:02 +03:00
|
|
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
2019-11-27 13:54:42 +03:00
|
|
|
|
|
|
|
$message = $this->_testMessage();
|
|
|
|
$message->senderName = null;
|
|
|
|
|
|
|
|
$user = $this->createMock(IUser::class);
|
|
|
|
$user->method('getDisplayName')->willReturn('Mr. Wizard');
|
|
|
|
|
|
|
|
$this->userManager->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('user123')
|
|
|
|
->willReturn($user);
|
|
|
|
|
|
|
|
$this->_expectSend();
|
|
|
|
$this->plugin->schedule($message);
|
|
|
|
$this->assertEquals('1.1', $message->getScheduleStatus());
|
|
|
|
}
|
|
|
|
|
2017-06-08 12:50:17 +03:00
|
|
|
/**
|
|
|
|
* @dataProvider dataNoMessageSendForPastEvents
|
|
|
|
*/
|
2020-03-26 20:32:09 +03:00
|
|
|
public function testNoMessageSendForPastEvents(array $veventParams, bool $expectsMail) {
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->config
|
2020-09-02 18:16:24 +03:00
|
|
|
->method('getAppValue')
|
|
|
|
->willReturn('yes');
|
2021-02-11 15:27:02 +03:00
|
|
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
2017-06-08 12:50:17 +03:00
|
|
|
|
2020-04-09 17:07:47 +03:00
|
|
|
$message = $this->_testMessage($veventParams);
|
2018-06-19 22:01:14 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->_expectSend('frodo@hobb.it', $expectsMail, $expectsMail);
|
2017-06-08 12:50:17 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->plugin->schedule($message);
|
2017-06-08 12:50:17 +03:00
|
|
|
|
|
|
|
if ($expectsMail) {
|
|
|
|
$this->assertEquals('1.1', $message->getScheduleStatus());
|
2019-11-27 13:54:42 +03:00
|
|
|
} else {
|
2017-06-08 12:50:17 +03:00
|
|
|
$this->assertEquals(false, $message->getScheduleStatus());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dataNoMessageSendForPastEvents() {
|
|
|
|
return [
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00')], false],
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00')], false],
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-12-31 00:00:00')], true],
|
2017-06-09 13:13:02 +03:00
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DURATION' => 'P1D'], false],
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DURATION' => 'P52W'], true],
|
2017-06-08 12:50:17 +03:00
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY'], true],
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY;COUNT=3'], false],
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY;UNTIL=20170301T000000Z'], false],
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY;COUNT=33'], true],
|
|
|
|
[['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY;UNTIL=20171001T000000Z'], true],
|
|
|
|
];
|
|
|
|
}
|
2019-02-28 04:22:53 +03:00
|
|
|
|
|
|
|
/**
|
2020-04-08 23:24:54 +03:00
|
|
|
* @dataProvider dataIncludeResponseButtons
|
|
|
|
*/
|
2020-04-09 14:53:40 +03:00
|
|
|
public function testIncludeResponseButtons(string $config_setting, string $recipient, bool $has_buttons) {
|
2019-02-28 04:25:27 +03:00
|
|
|
$message = $this->_testMessage([],$recipient);
|
2021-02-11 15:27:02 +03:00
|
|
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
2019-02-28 04:25:27 +03:00
|
|
|
|
|
|
|
$this->_expectSend($recipient, true, $has_buttons);
|
|
|
|
$this->config
|
2020-09-02 18:16:24 +03:00
|
|
|
->expects($this->at(1))
|
2019-07-18 02:47:15 +03:00
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'invitation_link_recipients', 'yes')
|
2019-02-28 04:22:53 +03:00
|
|
|
->willReturn($config_setting);
|
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->plugin->schedule($message);
|
|
|
|
$this->assertEquals('1.1', $message->getScheduleStatus());
|
|
|
|
}
|
2019-02-28 04:22:53 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
public function dataIncludeResponseButtons() {
|
|
|
|
return [
|
|
|
|
// dav.invitation_link_recipients, recipient, $has_buttons
|
2019-07-18 02:47:15 +03:00
|
|
|
[ 'yes', 'joe@internal.com', true],
|
2019-02-28 04:25:27 +03:00
|
|
|
[ 'joe@internal.com', 'joe@internal.com', true],
|
|
|
|
[ 'internal.com', 'joe@internal.com', true],
|
2019-07-18 02:47:15 +03:00
|
|
|
[ 'pete@otherinternal.com,internal.com', 'joe@internal.com', true],
|
|
|
|
[ 'no', 'joe@internal.com', false],
|
2019-02-28 04:25:27 +03:00
|
|
|
[ 'internal.com', 'joe@external.com', false],
|
2019-07-18 02:47:15 +03:00
|
|
|
[ 'jane@otherinternal.com,internal.com', 'joe@otherinternal.com', false],
|
2019-02-28 04:25:27 +03:00
|
|
|
];
|
|
|
|
}
|
2019-02-28 04:22:53 +03:00
|
|
|
|
2020-03-26 20:32:09 +03:00
|
|
|
public function testMessageSendWhenEventWithoutName() {
|
|
|
|
$this->config
|
|
|
|
->method('getAppValue')
|
|
|
|
->willReturn('yes');
|
2021-02-11 15:27:02 +03:00
|
|
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
2020-03-26 20:32:09 +03:00
|
|
|
|
|
|
|
$message = $this->_testMessage(['SUMMARY' => '']);
|
|
|
|
$this->_expectSend('frodo@hobb.it', true, true,'Invitation: Untitled event');
|
|
|
|
$this->emailTemplate->expects($this->once())
|
|
|
|
->method('addHeading')
|
2020-09-02 18:16:24 +03:00
|
|
|
->with('Invitation');
|
2020-03-26 20:32:09 +03:00
|
|
|
$this->plugin->schedule($message);
|
|
|
|
$this->assertEquals('1.1', $message->getScheduleStatus());
|
|
|
|
}
|
|
|
|
|
2020-04-09 14:53:40 +03:00
|
|
|
private function _testMessage(array $attrs = [], string $recipient = 'frodo@hobb.it') {
|
2019-02-28 04:22:53 +03:00
|
|
|
$message = new Message();
|
|
|
|
$message->method = 'REQUEST';
|
|
|
|
$message->message = new VCalendar();
|
2019-02-28 04:25:27 +03:00
|
|
|
$message->message->add('VEVENT', array_merge([
|
|
|
|
'UID' => 'uid-1234',
|
|
|
|
'SEQUENCE' => 0,
|
2019-02-28 04:22:53 +03:00
|
|
|
'SUMMARY' => 'Fellowship meeting',
|
2019-02-28 04:25:27 +03:00
|
|
|
'DTSTART' => new \DateTime('2018-01-01 00:00:00')
|
|
|
|
], $attrs));
|
2020-04-09 17:07:47 +03:00
|
|
|
$message->message->VEVENT->add('ORGANIZER', 'mailto:gandalf@wiz.ard');
|
|
|
|
$message->message->VEVENT->add('ATTENDEE', 'mailto:'.$recipient, [ 'RSVP' => 'TRUE' ]);
|
2019-02-28 04:22:53 +03:00
|
|
|
$message->sender = 'mailto:gandalf@wiz.ard';
|
2019-11-27 13:54:42 +03:00
|
|
|
$message->senderName = 'Mr. Wizard';
|
2019-02-28 04:22:53 +03:00
|
|
|
$message->recipient = 'mailto:'.$recipient;
|
2019-02-28 04:25:27 +03:00
|
|
|
return $message;
|
|
|
|
}
|
|
|
|
|
2019-02-28 04:22:53 +03:00
|
|
|
|
2020-03-26 20:32:09 +03:00
|
|
|
private function _expectSend(string $recipient = 'frodo@hobb.it', bool $expectSend = true, bool $expectButtons = true, string $subject = 'Invitation: Fellowship meeting') {
|
2019-02-28 04:25:27 +03:00
|
|
|
|
|
|
|
// if the event is in the past, we skip out
|
|
|
|
if (!$expectSend) {
|
|
|
|
$this->mailer
|
|
|
|
->expects($this->never())
|
|
|
|
->method('send');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->emailTemplate->expects($this->once())
|
2019-02-28 04:22:53 +03:00
|
|
|
->method('setSubject')
|
2020-03-26 20:32:09 +03:00
|
|
|
->with($subject);
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->mailMessage->expects($this->once())
|
2019-02-28 04:22:53 +03:00
|
|
|
->method('setTo')
|
|
|
|
->with([$recipient => null]);
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->mailMessage->expects($this->once())
|
2019-02-28 04:22:53 +03:00
|
|
|
->method('setReplyTo')
|
2019-11-27 13:54:42 +03:00
|
|
|
->with(['gandalf@wiz.ard' => 'Mr. Wizard']);
|
|
|
|
$this->mailMessage->expects($this->once())
|
|
|
|
->method('setFrom')
|
|
|
|
->with(['invitations-noreply@localhost' => 'Mr. Wizard via Instance Name 123']);
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->mailer
|
|
|
|
->expects($this->once())
|
|
|
|
->method('send');
|
2019-02-28 04:22:53 +03:00
|
|
|
|
2019-02-28 04:25:27 +03:00
|
|
|
if ($expectButtons) {
|
|
|
|
$this->queryBuilder->expects($this->at(0))
|
|
|
|
->method('insert')
|
|
|
|
->with('calendar_invitations')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($this->queryBuilder);
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->queryBuilder->expects($this->at(8))
|
|
|
|
->method('values')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($this->queryBuilder);
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->queryBuilder->expects($this->at(9))
|
|
|
|
->method('execute');
|
2020-04-10 15:19:56 +03:00
|
|
|
} else {
|
2019-02-28 04:25:27 +03:00
|
|
|
$this->queryBuilder->expects($this->never())
|
|
|
|
->method('insert')
|
|
|
|
->with('calendar_invitations');
|
|
|
|
}
|
2019-02-28 04:22:53 +03:00
|
|
|
}
|
2015-12-18 13:56:25 +03:00
|
|
|
}
|