+ /**
+ * Test sched reminder set via registration date.
+ */
+ public function testEventTypeRegistrationDate() {
+ //Create contact
+ $contactParams = array(
+ 'email' => 'test-event@example.com',
+ );
+ $contact = $this->individualCreate($contactParams);
+ //Add it as a participant to an event ending registration - 7 days from now.
+ $params = array(
+ 'start_date' => date('Ymd', strtotime('-5 day')),
+ 'end_date' => date('Ymd', strtotime('+7 day')),
+ 'registration_start_date' => date('Ymd', strtotime('-5 day')),
+ 'registration_end_date' => date('Ymd', strtotime('+7 day')),
+ );
+ $event = $this->eventCreate($params);
+ $this->participantCreate(array('contact_id' => $contact, 'event_id' => $event['id']));
+
+ //Create a scheduled reminder to send email 7 days before registration date.
+ $actionSchedule = $this->fixtures['sched_eventtype_start_1week_before'];
+ $actionSchedule['start_action_offset'] = 7;
+ $actionSchedule['start_action_unit'] = 'day';
+ $actionSchedule['start_action_date'] = 'registration_end_date';
+ $actionSchedule['entity_value'] = $event['values'][$event['id']]['event_type_id'];
+ $actionSchedule['entity_status'] = $this->callAPISuccessGetValue('ParticipantStatusType', array(
+ 'return' => "id",
+ 'name' => "Attended",
+ ));
+ $actionSched = $this->callAPISuccess('action_schedule', 'create', $actionSchedule);
+ //Run the cron and verify if an email was sent.
+ $this->assertCronRuns(array(
+ array(
+ 'time' => date('Y-m-d'),
+ 'recipients' => array(array('test-event@example.com')),
+ ),
+ ));
+
+ //Create contact 2
+ $contactParams = array(
+ 'email' => 'test-event2@example.com',
+ );
+ $contact2 = $this->individualCreate($contactParams);
+ //Create an event with registration end date = 2 week from now.
+ $params['end_date'] = date('Ymd', strtotime('+2 week'));
+ $params['registration_end_date'] = date('Ymd', strtotime('+2 week'));
+ $event2 = $this->eventCreate($params);
+ $this->participantCreate(array('contact_id' => $contact2, 'event_id' => $event2['id']));
+
+ //Assert there is no reminder sent to the contact.
+ $this->assertCronRuns(array(
+ array(
+ 'time' => date('Y-m-d'),
+ 'recipients' => array(),
+ ),
+ ));
+
+ //Modify the sched reminder to be sent 2 week from registration end date.
+ $this->callAPISuccess('action_schedule', 'create', array(
+ 'id' => $actionSched['id'],
+ 'start_action_offset' => 2,
+ 'start_action_unit' => 'week',
+ ));
+
+ //Contact should receive the reminder now.
+ $this->assertCronRuns(array(
+ array(
+ 'time' => date('Y-m-d'),
+ 'recipients' => array(array('test-event2@example.com')),
+ ),
+ ));
+ }
+
+ /**
+ * Test sched reminder set via start date.
+ */