ReminderServiceTest.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019, Thomas Citharel
  5. *
  6. * @author Thomas Citharel <tcit@tcit.fr>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\DAV\Tests\unit\CalDAV\Reminder;
  24. use OCA\DAV\CalDAV\CalDavBackend;
  25. use OCA\DAV\CalDAV\Reminder\AbstractNotificationProvider;
  26. use OCA\DAV\CalDAV\Reminder\Backend;
  27. use OCA\DAV\CalDAV\Reminder\INotificationProvider;
  28. use OCA\DAV\CalDAV\Reminder\NotificationProviderManager;
  29. use OCA\DAV\CalDAV\Reminder\NotificationProvider\EmailProvider;
  30. use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider;
  31. use OCA\DAV\CalDAV\Reminder\ReminderService;
  32. use OCP\AppFramework\Utility\ITimeFactory;
  33. use OCP\IGroup;
  34. use OCP\IGroupManager;
  35. use OCP\IUser;
  36. use OCP\IUserManager;
  37. use OCP\IUserSession;
  38. use Test\TestCase;
  39. class ReminderServiceTest extends TestCase {
  40. /** @var Backend|\PHPUnit\Framework\MockObject\MockObject */
  41. private $backend;
  42. /** @var NotificationProviderManager|\PHPUnit\Framework\MockObject\MockObject */
  43. private $notificationProviderManager;
  44. /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
  45. private $userManager;
  46. /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject*/
  47. private $groupManager;
  48. /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
  49. private $userSession;
  50. /** @var CalDavBackend|\PHPUnit\Framework\MockObject\MockObject */
  51. private $caldavBackend;
  52. /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
  53. private $timeFactory;
  54. /** @var ReminderService */
  55. private $reminderService;
  56. public const CALENDAR_DATA = <<<EOD
  57. BEGIN:VCALENDAR
  58. PRODID:-//Nextcloud calendar v1.6.4
  59. BEGIN:VEVENT
  60. CREATED:20160602T133732
  61. DTSTAMP:20160602T133732
  62. LAST-MODIFIED:20160602T133732
  63. UID:wej2z68l9h
  64. SUMMARY:Test Event
  65. LOCATION:Somewhere ...
  66. DESCRIPTION:maybe ....
  67. DTSTART;TZID=Europe/Berlin;VALUE=DATE:20160609
  68. DTEND;TZID=Europe/Berlin;VALUE=DATE:20160610
  69. BEGIN:VALARM
  70. ACTION:EMAIL
  71. TRIGGER:-PT15M
  72. END:VALARM
  73. BEGIN:VALARM
  74. ACTION:DISPLAY
  75. TRIGGER;VALUE=DATE-TIME:20160608T000000Z
  76. END:VALARM
  77. END:VEVENT
  78. END:VCALENDAR
  79. EOD;
  80. public const CALENDAR_DATA_REPEAT = <<<EOD
  81. BEGIN:VCALENDAR
  82. PRODID:-//Nextcloud calendar v1.6.4
  83. BEGIN:VEVENT
  84. CREATED:20160602T133732
  85. DTSTAMP:20160602T133732
  86. LAST-MODIFIED:20160602T133732
  87. UID:wej2z68l9h
  88. SUMMARY:Test Event
  89. LOCATION:Somewhere ...
  90. DESCRIPTION:maybe ....
  91. DTSTART;TZID=Europe/Berlin;VALUE=DATE:20160609
  92. DTEND;TZID=Europe/Berlin;VALUE=DATE:20160610
  93. BEGIN:VALARM
  94. ACTION:EMAIL
  95. TRIGGER:-PT15M
  96. REPEAT:4
  97. DURATION:PT2M
  98. END:VALARM
  99. END:VEVENT
  100. END:VCALENDAR
  101. EOD;
  102. public const CALENDAR_DATA_RECURRING = <<<EOD
  103. BEGIN:VCALENDAR
  104. PRODID:-//Nextcloud calendar v1.6.4
  105. BEGIN:VEVENT
  106. CREATED:20160602T133732
  107. DTSTAMP:20160602T133732
  108. LAST-MODIFIED:20160602T133732
  109. UID:wej2z68l9h
  110. SUMMARY:Test Event
  111. LOCATION:Somewhere ...
  112. DESCRIPTION:maybe ....
  113. DTSTART;TZID=Europe/Berlin;VALUE=DATE:20160609
  114. DTEND;TZID=Europe/Berlin;VALUE=DATE:20160610
  115. RRULE:FREQ=WEEKLY
  116. BEGIN:VALARM
  117. ACTION:EMAIL
  118. TRIGGER:-PT15M
  119. END:VALARM
  120. BEGIN:VALARM
  121. ACTION:EMAIL
  122. TRIGGER:-P8D
  123. END:VALARM
  124. END:VEVENT
  125. END:VCALENDAR
  126. EOD;
  127. public const CALENDAR_DATA_RECURRING_REPEAT = <<<EOD
  128. BEGIN:VCALENDAR
  129. PRODID:-//Nextcloud calendar v1.6.4
  130. BEGIN:VEVENT
  131. CREATED:20160602T133732
  132. DTSTAMP:20160602T133732
  133. LAST-MODIFIED:20160602T133732
  134. UID:wej2z68l9h
  135. SUMMARY:Test Event
  136. LOCATION:Somewhere ...
  137. DESCRIPTION:maybe ....
  138. DTSTART;TZID=Europe/Berlin;VALUE=DATE:20160609
  139. DTEND;TZID=Europe/Berlin;VALUE=DATE:20160610
  140. RRULE:FREQ=WEEKLY
  141. BEGIN:VALARM
  142. ACTION:EMAIL
  143. TRIGGER:-PT15M
  144. REPEAT:4
  145. DURATION:PT2M
  146. END:VALARM
  147. BEGIN:VALARM
  148. ACTION:EMAIL
  149. TRIGGER:-P8D
  150. END:VALARM
  151. END:VEVENT
  152. END:VCALENDAR
  153. EOD;
  154. public function setUp() {
  155. parent::setUp();
  156. $this->backend = $this->createMock(Backend::class);
  157. $this->notificationProviderManager = $this->createMock(NotificationProviderManager::class);
  158. $this->userManager = $this->createMock(IUserManager::class);
  159. $this->groupManager = $this->createMock(IGroupManager::class);
  160. $this->caldavBackend = $this->createMock(CalDavBackend::class);
  161. $this->timeFactory = $this->createMock(ITimeFactory::class);
  162. $this->caldavBackend->method('getShares')->willReturn([]);
  163. $this->reminderService = new ReminderService($this->backend,
  164. $this->notificationProviderManager,
  165. $this->userManager,
  166. $this->groupManager,
  167. $this->caldavBackend,
  168. $this->timeFactory);
  169. }
  170. public function testOnCalendarObjectDelete():void {
  171. $this->backend->expects($this->once())
  172. ->method('cleanRemindersForEvent')
  173. ->with(44);
  174. $action = '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject';
  175. $objectData = [
  176. 'id' => '44',
  177. 'component' => 'vevent',
  178. ];
  179. $this->reminderService->onTouchCalendarObject($action, $objectData);
  180. }
  181. public function testOnCalendarObjectCreateSingleEntry():void {
  182. $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject';
  183. $objectData = [
  184. 'calendardata' => self::CALENDAR_DATA,
  185. 'id' => '42',
  186. 'calendarid' => '1337',
  187. 'component' => 'vevent',
  188. ];
  189. $this->backend->expects($this->exactly(2))
  190. ->method('insertReminder')
  191. ->withConsecutive(
  192. [1337, 42, 'wej2z68l9h', false, 1465430400, false, '5c70531aab15c92b52518ae10a2f78a4', 'de919af7429d3b5c11e8b9d289b411a6', 'EMAIL', true, 1465429500, false],
  193. [1337, 42, 'wej2z68l9h', false, 1465430400, false, '5c70531aab15c92b52518ae10a2f78a4', '35b3eae8e792aa2209f0b4e1a302f105', 'DISPLAY', false, 1465344000, false]
  194. )
  195. ->willReturn(1);
  196. $this->timeFactory->expects($this->once())
  197. ->method('getDateTime')
  198. ->with()
  199. ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-08T00:00:00+00:00'));
  200. $this->reminderService->onTouchCalendarObject($action, $objectData);
  201. }
  202. public function testOnCalendarObjectCreateSingleEntryWithRepeat(): void {
  203. $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject';
  204. $objectData = [
  205. 'calendardata' => self::CALENDAR_DATA_REPEAT,
  206. 'id' => '42',
  207. 'calendarid' => '1337',
  208. 'component' => 'vevent',
  209. ];
  210. $this->backend->expects($this->exactly(5))
  211. ->method('insertReminder')
  212. ->withConsecutive(
  213. [1337, 42, 'wej2z68l9h', false, 1465430400, false, '5c70531aab15c92b52518ae10a2f78a4', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1465429500, false],
  214. [1337, 42, 'wej2z68l9h', false, 1465430400, false, '5c70531aab15c92b52518ae10a2f78a4', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1465429620, true],
  215. [1337, 42, 'wej2z68l9h', false, 1465430400, false, '5c70531aab15c92b52518ae10a2f78a4', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1465429740, true],
  216. [1337, 42, 'wej2z68l9h', false, 1465430400, false, '5c70531aab15c92b52518ae10a2f78a4', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1465429860, true],
  217. [1337, 42, 'wej2z68l9h', false, 1465430400, false, '5c70531aab15c92b52518ae10a2f78a4', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1465429980, true]
  218. )
  219. ->willReturn(1);
  220. $this->timeFactory->expects($this->once())
  221. ->method('getDateTime')
  222. ->with()
  223. ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-08T00:00:00+00:00'));
  224. $this->reminderService->onTouchCalendarObject($action, $objectData);
  225. }
  226. public function testOnCalendarObjectCreateRecurringEntry(): void {
  227. $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject';
  228. $objectData = [
  229. 'calendardata' => self::CALENDAR_DATA_RECURRING,
  230. 'id' => '42',
  231. 'calendarid' => '1337',
  232. 'component' => 'vevent',
  233. ];
  234. $this->backend->expects($this->exactly(2))
  235. ->method('insertReminder')
  236. ->withConsecutive(
  237. [1337, 42, 'wej2z68l9h', true, 1467244800, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'de919af7429d3b5c11e8b9d289b411a6', 'EMAIL', true, 1467243900, false],
  238. [1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', '8996992118817f9f311ac5cc56d1cc97', 'EMAIL', true, 1467158400, false]
  239. )
  240. ->willReturn(1);
  241. $this->timeFactory->expects($this->once())
  242. ->method('getDateTime')
  243. ->with()
  244. ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-29T00:00:00+00:00'));
  245. $this->reminderService->onTouchCalendarObject($action, $objectData);
  246. }
  247. public function testOnCalendarObjectCreateRecurringEntryWithRepeat():void {
  248. $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject';
  249. $objectData = [
  250. 'calendardata' => self::CALENDAR_DATA_RECURRING_REPEAT,
  251. 'id' => '42',
  252. 'calendarid' => '1337',
  253. 'component' => 'vevent',
  254. ];
  255. $this->backend->expects($this->exactly(6))
  256. ->method('insertReminder')
  257. ->withConsecutive(
  258. [1337, 42, 'wej2z68l9h', true, 1467244800, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467243900, false],
  259. [1337, 42, 'wej2z68l9h', true, 1467244800, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467244020, true],
  260. [1337, 42, 'wej2z68l9h', true, 1467244800, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467244140, true],
  261. [1337, 42, 'wej2z68l9h', true, 1467244800, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467244260, true],
  262. [1337, 42, 'wej2z68l9h', true, 1467244800, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467244380, true],
  263. [1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', '8996992118817f9f311ac5cc56d1cc97', 'EMAIL', true, 1467158400, false]
  264. )
  265. ->willReturn(1);
  266. $this->timeFactory->expects($this->once())
  267. ->method('getDateTime')
  268. ->with()
  269. ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-29T00:00:00+00:00'));
  270. $this->reminderService->onTouchCalendarObject($action, $objectData);
  271. }
  272. public function testProcessReminders():void {
  273. $this->backend->expects($this->at(0))
  274. ->method('getRemindersToProcess')
  275. ->with()
  276. ->willReturn([
  277. [
  278. 'id' => 1,
  279. 'calendar_id' => 1337,
  280. 'object_id' => 42,
  281. 'uid' => 'wej2z68l9h',
  282. 'is_recurring' => false,
  283. 'recurrence_id' => 1465430400,
  284. 'is_recurrence_exception' => false,
  285. 'event_hash' => '5c70531aab15c92b52518ae10a2f78a4',
  286. 'alarm_hash' => 'de919af7429d3b5c11e8b9d289b411a6',
  287. 'type' => 'EMAIL',
  288. 'is_relative' => true,
  289. 'notification_date' => 1465429500,
  290. 'is_repeat_based' => false,
  291. 'calendardata' => self::CALENDAR_DATA,
  292. 'displayname' => 'Displayname 123',
  293. 'principaluri' => 'principals/users/user001',
  294. ],
  295. [
  296. 'id' => 2,
  297. 'calendar_id' => 1337,
  298. 'object_id' => 42,
  299. 'uid' => 'wej2z68l9h',
  300. 'is_recurring' => false,
  301. 'recurrence_id' => 1465430400,
  302. 'is_recurrence_exception' => false,
  303. 'event_hash' => '5c70531aab15c92b52518ae10a2f78a4',
  304. 'alarm_hash' => 'ecacbf07d413c3c78d1ac7ad8c469602',
  305. 'type' => 'EMAIL',
  306. 'is_relative' => true,
  307. 'notification_date' => 1465429740,
  308. 'is_repeat_based' => true,
  309. 'calendardata' => self::CALENDAR_DATA_REPEAT,
  310. 'displayname' => 'Displayname 123',
  311. 'principaluri' => 'principals/users/user001',
  312. ],
  313. [
  314. 'id' => 3,
  315. 'calendar_id' => 1337,
  316. 'object_id' => 42,
  317. 'uid' => 'wej2z68l9h',
  318. 'is_recurring' => false,
  319. 'recurrence_id' => 1465430400,
  320. 'is_recurrence_exception' => false,
  321. 'event_hash' => '5c70531aab15c92b52518ae10a2f78a4',
  322. 'alarm_hash' => '35b3eae8e792aa2209f0b4e1a302f105',
  323. 'type' => 'DISPLAY',
  324. 'is_relative' => false,
  325. 'notification_date' => 1465344000,
  326. 'is_repeat_based' => false,
  327. 'calendardata' => self::CALENDAR_DATA,
  328. 'displayname' => 'Displayname 123',
  329. 'principaluri' => 'principals/users/user001',
  330. ],
  331. [
  332. 'id' => 4,
  333. 'calendar_id' => 1337,
  334. 'object_id' => 42,
  335. 'uid' => 'wej2z68l9h',
  336. 'is_recurring' => true,
  337. 'recurrence_id' => 1467244800,
  338. 'is_recurrence_exception' => false,
  339. 'event_hash' => 'fbdb2726bc0f7dfacac1d881c1453e20',
  340. 'alarm_hash' => 'ecacbf07d413c3c78d1ac7ad8c469602',
  341. 'type' => 'EMAIL',
  342. 'is_relative' => true,
  343. 'notification_date' => 1467243900,
  344. 'is_repeat_based' => false,
  345. 'calendardata' => self::CALENDAR_DATA_RECURRING_REPEAT,
  346. 'displayname' => 'Displayname 123',
  347. 'principaluri' => 'principals/users/user001',
  348. ],
  349. [
  350. 'id' => 5,
  351. 'calendar_id' => 1337,
  352. 'object_id' => 42,
  353. 'uid' => 'wej2z68l9h',
  354. 'is_recurring' => true,
  355. 'recurrence_id' => 1467849600,
  356. 'is_recurrence_exception' => false,
  357. 'event_hash' => 'fbdb2726bc0f7dfacac1d881c1453e20',
  358. 'alarm_hash' => '8996992118817f9f311ac5cc56d1cc97',
  359. 'type' => 'EMAIL',
  360. 'is_relative' => true,
  361. 'notification_date' => 1467158400,
  362. 'is_repeat_based' => false,
  363. 'calendardata' => self::CALENDAR_DATA_RECURRING,
  364. 'displayname' => 'Displayname 123',
  365. 'principaluri' => 'principals/users/user001',
  366. ]
  367. ]);
  368. $this->notificationProviderManager->expects($this->at(0))
  369. ->method('hasProvider')
  370. ->with('EMAIL')
  371. ->willReturn(true);
  372. $provider1 = $this->createMock(INotificationProvider::class);
  373. $this->notificationProviderManager->expects($this->at(1))
  374. ->method('getProvider')
  375. ->with('EMAIL')
  376. ->willReturn($provider1);
  377. $this->notificationProviderManager->expects($this->at(2))
  378. ->method('hasProvider')
  379. ->with('EMAIL')
  380. ->willReturn(true);
  381. $provider2 = $this->createMock(INotificationProvider::class);
  382. $this->notificationProviderManager->expects($this->at(3))
  383. ->method('getProvider')
  384. ->with('EMAIL')
  385. ->willReturn($provider2);
  386. $this->notificationProviderManager->expects($this->at(4))
  387. ->method('hasProvider')
  388. ->with('DISPLAY')
  389. ->willReturn(true);
  390. $provider3 = $this->createMock(INotificationProvider::class);
  391. $this->notificationProviderManager->expects($this->at(5))
  392. ->method('getProvider')
  393. ->with('DISPLAY')
  394. ->willReturn($provider3);
  395. $this->notificationProviderManager->expects($this->at(6))
  396. ->method('hasProvider')
  397. ->with('EMAIL')
  398. ->willReturn(true);
  399. $provider4 = $this->createMock(INotificationProvider::class);
  400. $this->notificationProviderManager->expects($this->at(7))
  401. ->method('getProvider')
  402. ->with('EMAIL')
  403. ->willReturn($provider4);
  404. $this->notificationProviderManager->expects($this->at(8))
  405. ->method('hasProvider')
  406. ->with('EMAIL')
  407. ->willReturn(true);
  408. $provider5 = $this->createMock(INotificationProvider::class);
  409. $this->notificationProviderManager->expects($this->at(9))
  410. ->method('getProvider')
  411. ->with('EMAIL')
  412. ->willReturn($provider5);
  413. $user = $this->createMock(IUser::class);
  414. $this->userManager->expects($this->exactly(5))
  415. ->method('get')
  416. ->with('user001')
  417. ->willReturn($user);
  418. $provider1->expects($this->once())
  419. ->method('send')
  420. ->with($this->callback(function($vevent) {
  421. if ($vevent->DTSTART->getDateTime()->format(\DateTime::ATOM) !== '2016-06-09T00:00:00+00:00') {
  422. return false;
  423. }
  424. return true;
  425. }, 'Displayname 123', $user));
  426. $provider2->expects($this->once())
  427. ->method('send')
  428. ->with($this->callback(function($vevent) {
  429. if ($vevent->DTSTART->getDateTime()->format(\DateTime::ATOM) !== '2016-06-09T00:00:00+00:00') {
  430. return false;
  431. }
  432. return true;
  433. }, 'Displayname 123', $user));
  434. $provider3->expects($this->once())
  435. ->method('send')
  436. ->with($this->callback(function($vevent) {
  437. if ($vevent->DTSTART->getDateTime()->format(\DateTime::ATOM) !== '2016-06-09T00:00:00+00:00') {
  438. return false;
  439. }
  440. return true;
  441. }, 'Displayname 123', $user));
  442. $provider4->expects($this->once())
  443. ->method('send')
  444. ->with($this->callback(function($vevent) {
  445. if ($vevent->DTSTART->getDateTime()->format(\DateTime::ATOM) !== '2016-06-30T00:00:00+00:00') {
  446. return false;
  447. }
  448. return true;
  449. }, 'Displayname 123', $user));
  450. $provider5->expects($this->once())
  451. ->method('send')
  452. ->with($this->callback(function($vevent) {
  453. if ($vevent->DTSTART->getDateTime()->format(\DateTime::ATOM) !== '2016-07-07T00:00:00+00:00') {
  454. return false;
  455. }
  456. return true;
  457. }, 'Displayname 123', $user));
  458. $this->backend->expects($this->at(1))
  459. ->method('removeReminder')
  460. ->with(1);
  461. $this->backend->expects($this->at(2))
  462. ->method('removeReminder')
  463. ->with(2);
  464. $this->backend->expects($this->at(3))
  465. ->method('removeReminder')
  466. ->with(3);
  467. $this->backend->expects($this->at(4))
  468. ->method('removeReminder')
  469. ->with(4);
  470. $this->backend->expects($this->at(5))
  471. ->method('insertReminder')
  472. ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848700, false)
  473. ->willReturn(99);
  474. $this->backend->expects($this->at(6))
  475. ->method('insertReminder')
  476. ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848820, true)
  477. ->willReturn(99);
  478. $this->backend->expects($this->at(7))
  479. ->method('insertReminder')
  480. ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848940, true)
  481. ->willReturn(99);
  482. $this->backend->expects($this->at(8))
  483. ->method('insertReminder')
  484. ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467849060, true)
  485. ->willReturn(99);
  486. $this->backend->expects($this->at(9))
  487. ->method('insertReminder')
  488. ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467849180, true)
  489. ->willReturn(99);
  490. $this->backend->expects($this->at(10))
  491. ->method('removeReminder')
  492. ->with(5);
  493. $this->backend->expects($this->at(11))
  494. ->method('insertReminder')
  495. ->with(1337, 42, 'wej2z68l9h', true, 1468454400, false, 'fbdb2726bc0f7dfacac1d881c1453e20', '8996992118817f9f311ac5cc56d1cc97', 'EMAIL', true, 1467763200, false)
  496. ->willReturn(99);
  497. $this->timeFactory->method('getDateTime')
  498. ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-08T00:00:00+00:00'));
  499. $this->reminderService->processReminders();
  500. }
  501. }