You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReminderServiceTest.php 19KB

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