+
+ // CASE 2: Create a schedule reminder which was created 1 day after the schdule day,
+ // so it shouldn't deliver reminders schedule to send 1 week before the event start date
+ $actionSchedule = $this->fixtures['sched_event_type_start_1week_before'];
+ $actionSchedule['entity_value'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'event_type_id');
+ $actionSchedule['effective_start_date'] = '20120309000000';
+ $this->callAPISuccess('action_schedule', 'create', $actionSchedule);
+ // end_date=2012-06-15 ; schedule is 2 weeks before end_date
+ $this->assertCronRuns([
+ [
+ // 2 weeks before
+ 'time' => '2012-03-02 01:00:00',
+ 'recipients' => [],
+ ],
+ [
+ // 1 week before
+ 'time' => '2012-03-08 01:00:00',
+ 'recipients' => [],
+ ],
+ [
+ // And then nothing else
+ 'time' => '2012-03-16 01:00:00',
+ 'recipients' => [],
+ ],
+ ]);
+
+ // CASE 3: Create a schedule reminder which is created less then a week before the event start date,
+ // so it should deliver reminders schedule to send 1 week before the event start date, set the effective end date just an hour later the reminder delivery date
+ $actionSchedule = $this->fixtures['sched_event_type_start_1week_before'];
+ $actionSchedule['entity_value'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'event_type_id');
+ $actionSchedule['effective_end_date'] = '20120309010000';
+ $this->callAPISuccess('action_schedule', 'create', $actionSchedule);
+ // end_date=2012-06-15 ; schedule is 2 weeks before end_date
+ $this->assertCronRuns([
+ [
+ // 2 weeks before
+ 'time' => '2012-03-02 01:00:00',
+ 'recipients' => [],
+ ],
+ [
+ // 1 week before
+ 'time' => '2012-03-08 01:00:00',
+ 'recipients' => [['test-event@example.com']],
+ ],
+ [
+ // And then nothing else
+ 'time' => '2012-03-16 01:00:00',
+ 'recipients' => [],
+ ],
+ ]);