Commit 206c0c43 authored by priyankakaran26's avatar priyankakaran26 Committed by deepak.srivastava

towards recursion object tests

parent dfbe9b91
......@@ -94,11 +94,15 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
}
function mode($mode) {
$this->mode = $mode;
if (!$this->parent_id) {
$this->parent_id = $this->entity_id;
if ($this->entity_id && $this->entity_table) {
if ($this->find(TRUE)) {
$this->mode = $mode;
} else {
$this->parent_id = $this->entity_id;
$this->mode = $mode;
}
$this->save();
}
$this->save();
}
// generate all new entities based on object vars
......@@ -613,79 +617,4 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
}
return $participantDetails;
}
static function testActivityGeneration() {
//Activity set initial params
$daoActivity = new CRM_Activity_DAO_Activity();
$daoActivity->activity_type_id = 1;
$daoActivity->subject = "Initial Activity";
$daoActivity->activity_date_time = date('YmdHis');
$daoActivity->save();
$recursion = new CRM_Core_BAO_RecurringEntity();
$recursion->entity_id = $daoActivity->id;
$recursion->entity_table = 'civicrm_activity';
$recursion->dateColumns = array('activity_date_time');
$recursion->scheduleDBParams = array(
'entity_value' => $daoActivity->id,
'entity_status' => $daoActivity->activity_date_time,
'start_action_date' => 'fourth saturday',
'repetition_frequency_unit' => 'month',
'repetition_frequency_interval' => 3,
'start_action_offset' => 5,
'used_for' => 'activity'
);
$generatedEntities = $recursion->generate();
// try changing something
$recursion->mode(3); // sets ->mode var & saves in DB
// lets change subject of initial activity that we created in begining
$daoActivity->find(TRUE);
$daoActivity->subject = 'I changed it';
$daoActivity->save();
}
static function testEventGeneration(){
//Event set initial params
$daoEvent = new CRM_Event_DAO_Event();
$daoEvent->title = 'Test event for Recurring Entity';
$daoEvent->event_type_id = 3;
$daoEvent->is_public = 1;
$daoEvent->start_date = date('YmdHis', strtotime('2014-09-24 10:30:00'));
$daoEvent->end_date = date('YmdHis', strtotime('2014-09-26 10:30:00'));
$daoEvent->created_date = date('YmdHis');
$daoEvent->is_active = 1;
$daoEvent->save();
$recursion = new CRM_Core_BAO_RecurringEntity();
$recursion->entity_id = $daoEvent->id;
$recursion->entity_table = 'civicrm_event';
$recursion->dateColumns = array('start_date');
$recursion->scheduleDBParams = array (
'entity_value' => $daoEvent->id,
'entity_status' => $daoEvent->start_date,
'start_action_condition' => 'wednesday',
'repetition_frequency_unit' => 'week',
'repetition_frequency_interval' => 1,
'start_action_offset' => 4,
'used_for' => 'event'
);
$interval = $recursion->getInterval($daoEvent->start_date, $daoEvent->end_date);
$recursion->intervalDateColumns = array('end_date' => $interval);
$recursion->excludeDates = array(date('Ymd', strtotime('2014-10-02')), '20141008');// = array('date1', date2, date2)
$recursion->excludeDateRangeColumns = array('start_date', 'end_date');
$generatedEntities = $recursion->generate();
// try changing something
$recursion->mode(3); // sets ->mode var & saves in DB
$daoEvent->find(TRUE);
$daoEvent->title = 'I changed event';
$daoEvent->save();
}
}
......@@ -62,7 +62,7 @@ function domain_get_expectedresult(){
'id' => '2',
'name' => 'Second Domain',
'config_backend' => 'a:83:{s:18:\"fatalErrorTemplate\";s:20:\"CRM/common/fatal.tpl\";s:15:\"civiRelativeURL\";s:13:\"/index.php?q=\";s:11:\"civiVersion\";s:9:\"4.5.beta9\";s:11:\"empoweredBy\";b:1;s:10:\"userSystem\";O:26:\"CRM_Utils_System_UnitTests\":5:{s:19:\"supports_UF_Logging\";b:1;s:9:\"is_drupal\";b:0;s:9:\"is_joomla\";b:0;s:12:\"is_wordpress\";b:0;s:24:\"supports_form_extensions\";b:0;}s:11:\"initialized\";i:0;s:15:\"DAOFactoryClass\";s:23:\"CRM_Contact_DAO_Factory\";s:17:\"componentRegistry\";O:18:\"CRM_Core_Component\":0:{}s:9:\"inCiviCRM\";b:0;s:18:\"recaptchaPublicKey\";N;s:5:\"debug\";i:0;s:9:\"backtrace\";i:0;s:12:\"resourceBase\";N;s:13:\"extensionsURL\";N;s:12:\"countryLimit\";a:1:{i:0;s:4:\"1228\";}s:27:\"defaultContactStateProvince\";N;s:13:\"provinceLimit\";a:1:{i:0;s:4:\"1228\";}s:21:\"defaultContactCountry\";s:4:\"1228\";s:15:\"defaultCurrency\";s:3:\"USD\";s:10:\"lcMessages\";s:5:\"en_US\";s:18:\"dateformatDatetime\";s:20:\"%B %E%f, %Y %l:%M %P\";s:14:\"dateformatFull\";s:11:\"%B %E%f, %Y\";s:17:\"dateformatPartial\";s:5:\"%B %Y\";s:14:\"dateformatYear\";s:2:\"%Y\";s:14:\"dateformatTime\";s:8:\"%l:%M %P\";s:15:\"timeInputFormat\";i:1;s:15:\"dateInputFormat\";s:8:\"mm/dd/yy\";s:15:\"fiscalYearStart\";a:2:{s:1:\"M\";i:1;s:1:\"d\";i:1;}s:11:\"moneyformat\";s:5:\"%c %a\";s:16:\"moneyvalueformat\";s:3:\"%!i\";s:15:\"currencySymbols\";s:0:\"\";s:21:\"defaultCurrencySymbol\";s:1:\"$\";s:20:\"monetaryDecimalPoint\";s:1:\".\";s:25:\"monetaryThousandSeparator\";s:1:\",\";s:14:\"gettextCodeset\";s:5:\"utf-8\";s:13:\"gettextDomain\";s:7:\"civicrm\";s:27:\"userFrameworkUsersTableName\";s:5:\"users\";s:21:\"userFrameworkFrontend\";b:0;s:20:\"userFrameworkLogging\";b:0;s:17:\"maxImportFileSize\";i:2097152;s:11:\"maxFileSize\";i:2;s:11:\"mapProvider\";N;s:9:\"mapAPIKey\";N;s:11:\"geoProvider\";N;s:9:\"geoAPIKey\";N;s:13:\"geocodeMethod\";s:0:\"\";s:12:\"mapGeoCoding\";i:1;s:7:\"logging\";b:0;s:12:\"versionCheck\";b:1;s:16:\"enableComponents\";a:6:{i:0;s:14:\"CiviContribute\";i:1;s:10:\"CiviPledge\";i:2;s:10:\"CiviMember\";i:3;s:9:\"CiviEvent\";i:4;s:8:\"CiviMail\";i:5;s:10:\"CiviReport\";}s:18:\"enableComponentIDs\";a:6:{i:0;i:1;i:1;i:6;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:8;}s:9:\"enableSSL\";b:0;s:17:\"fatalErrorHandler\";N;s:14:\"legacyEncoding\";s:12:\"Windows-1252\";s:14:\"fieldSeparator\";s:1:\",\";s:17:\"maxLocationBlocks\";i:2;s:15:\"captchaFontPath\";s:25:\"/usr/X11R6/lib/X11/fonts/\";s:11:\"captchaFont\";s:17:\"HelveticaBold.ttf\";s:21:\"includeWildCardInName\";i:1;s:18:\"includeEmailInName\";i:1;s:21:\"includeNickNameInName\";i:0;s:22:\"smartGroupCacheTimeout\";i:5;s:22:\"defaultSearchProfileID\";N;s:21:\"dashboardCacheTimeout\";i:1440;s:15:\"doNotResetCache\";i:0;s:24:\"includeAlphabeticalPager\";i:1;s:20:\"includeOrderByClause\";i:1;s:13:\"oldInputStyle\";i:1;s:14:\"formKeyDisable\";b:0;s:21:\"doNotAttachPDFReceipt\";b:0;s:15:\"wkhtmltopdfPath\";b:0;s:23:\"secondDegRelPermissions\";b:0;s:10:\"wpBasePage\";N;s:9:\"groupTree\";b:0;s:11:\"revampPages\";a:0:{}s:13:\"verpSeparator\";s:1:\".\";s:12:\"mailerPeriod\";i:180;s:16:\"mailerSpoolLimit\";i:0;s:16:\"mailerBatchLimit\";i:0;s:13:\"mailerJobSize\";i:0;s:13:\"mailerJobsMax\";i:0;s:16:\"mailThrottleTime\";i:0;s:12:\"customCSSURL\";N;}',
'version' => '4.3.alpha1',
'version' => '4.6.alpha1',
'contact_id' => '2',
'domain_email' => '\"Domain Email\" <domainemail2@example.org>',
'domain_phone' => array(
......
......@@ -1017,5 +1017,4 @@ INSERT INTO civicrm_navigation
VALUES
( @domainID, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), 'Mailing Detail Report', 'Mailing Detail Report', 'administer CiviMail', 'OR', @reportlastID, '1', NULL, @instanceID+2 );
UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;
UPDATE civicrm_domain SET version = '4.3.alpha1';
UPDATE civicrm_domain SET version = '4.6.alpha1';
......@@ -65,16 +65,12 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
* Testing Activity Generation through Entity Recursion
*/
function testActivityGeneration() {
//create an activity
//Activity set initial params
$daoActivity = new CRM_Activity_DAO_Activity();
$daoActivity->activity_type_id = 1;
$daoActivity->subject = "Initial Activity";
$daoActivity->activity_date_time = date('YmdHis');
$daoActivity->save();
$this->assertDBNotNull('CRM_Activity_DAO_Activity', $daoActivity->id, 'id',
'id', 'Check DB if activity was created'
);
$recursion = new CRM_Core_BAO_RecurringEntity();
$recursion->entity_id = $daoActivity->id;
......@@ -87,8 +83,9 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
'repetition_frequency_unit' => 'month',
'repetition_frequency_interval' => 3,
'start_action_offset' => 5,
'used_for' => 'activity'
'used_for' => 'activity'
);
$generatedEntities = $recursion->generate();
foreach ($generatedEntities as $entityID) {
$this->assertDBNotNull('CRM_Activity_DAO_Activity', $entityID, 'id',
......@@ -96,8 +93,8 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
);
}
// try changing something
$recursion->mode(3); // sets ->mode var & saves in DB
// set mode to ALL, i.e any change to changing activity affects all related recurring activities
$recursion->mode(3);
// lets change subject of initial activity that we created in begining
$daoActivity->find(TRUE);
......@@ -120,7 +117,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
$daoEvent->event_type_id = 3;
$daoEvent->is_public = 1;
$daoEvent->start_date = date('YmdHis', strtotime('2014-09-24 10:30:00'));
$daoEvent->end_date = date('YmdHis', strtotime('2014-09-26 10:30:00'));
$daoEvent->end_date = date('YmdHis', strtotime('2014-09-26 10:30:00'));
$daoEvent->created_date = date('YmdHis');
$daoEvent->is_active = 1;
$daoEvent->save();
......@@ -139,17 +136,10 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
'used_for' => 'event'
);
//$interval = $recursion->getInterval($daoEvent->start_date, $daoEvent->end_date);
//$recursion->intervalDateColumns = array('end_date' => $interval);
//$recursion->excludeDates = array(date('Ymd', strtotime('2014-10-02')), '20141008');// = array('date1', date2, date2)
//$recursion->excludeDateRangeColumns = array('start_date', 'end_date');
$generatedEntities = $recursion->generate();
CRM_Core_Error::debug_var('$generatedEntities', $generatedEntities);
// try changing something
$recursion->mode(3); // sets ->mode var & saves in DB
// set mode to ALL, i.e any change to changing event affects all related recurring activities
$recursion->mode(3);
$daoEvent->find(TRUE);
$daoEvent->title = 'Event Changed';
......@@ -160,7 +150,4 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
$this->assertDBCompareValue('CRM_Event_DAO_Event', $entityID, 'title', 'id', 'Event Changed', 'Check if title was updated');
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment