* Testing Event Generation through Entity Recursion
*/
function testEventGeneration() {
- //Event set initial params
+ //Event set initial params
$daoEvent = new CRM_Event_DAO_Event();
$daoEvent->title = 'Test event for Recurring Entity';
$daoEvent->event_type_id = 3;
foreach ($generatedEntities['civicrm_event'] as $entityID) {
$this->assertDBCompareValue('CRM_Event_DAO_Event', $entityID, 'title', 'id', 'Event Changed', 'Check if title was updated');
}
+
+ end($generatedEntities['civicrm_event']);
+ $key = key($generatedEntities['civicrm_event']);
+
+ end($generatedEntities['civicrm_tell_friend']);
+ $actKey = key($generatedEntities['civicrm_tell_friend']);
+
+ //Check if both(event/tell a friend) keys are same
+ $this->assertEquals($key, $actKey, "Check if both the keys are same");
+
+ //Cross check event exists before we test deletion
+ $searchParamsEventBeforeDelete = array('entity_id' => $generatedEntities['civicrm_event'][$key],
+ 'entity_table' => 'civicrm_event'
+ );
+ $expectedValuesEventBeforeDelete = array('entity_id' => $generatedEntities['civicrm_event'][$key],
+ 'entity_table' => 'civicrm_event'
+ );
+ $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsEventBeforeDelete, $expectedValuesEventBeforeDelete);
+
+ //Cross check event exists before we test deletion
+ $searchParamsTellAFriendBeforeDelete = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey],
+ 'entity_table' => 'civicrm_tell_friend'
+ );
+ $expectedValuesTellAFriendBeforeDelete = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey],
+ 'entity_table' => 'civicrm_tell_friend'
+ );
+ $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsTellAFriendBeforeDelete, $expectedValuesTellAFriendBeforeDelete);
+
+ //Delete an event from recurring set and respective linked entity should be deleted from civicrm_recurring_entity_table
+ $daoRecurEvent = new CRM_Event_DAO_Event();
+ $daoRecurEvent->id = $generatedEntities['civicrm_event'][$key];
+ if ($daoRecurEvent->find(TRUE)) {
+ $daoRecurEvent->delete();
+ $daoRecurEvent->free();
+ }
+
+ //Check if this event_id was deleted
+ $this->assertDBNull('CRM_Event_DAO_Event', $generatedEntities['civicrm_event'][$key], 'id', 'id', 'Check if event was deleted');
+ $searchParams = array('entity_id' => $generatedEntities['civicrm_event'][$key],
+ 'entity_table' => 'civicrm_event'
+ );
+ $compareParams = array();
+ $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParams, $compareParams);
+
+ //Find tell_a_friend id if that was deleted from civicrm
+ $searchActParams = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey],
+ 'entity_table' => 'civicrm_tell_friend'
+ );
+ $compareActParams = array();
+ $this->assertDBCompareValues('CRM_Friend_DAO_Friend', $searchActParams, $compareActParams);
}
}