[REF] Add in upgrade step to populate missing contact_type.name field
[civicrm-core.git] / tests / phpunit / CRM / Upgrade / Incremental / BaseTest.php
1 <?php
2
3 /**
4 * Class CRM_UF_Page_ProfileEditorTest
5 * @group headless
6 */
7 class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase {
8 use CRMTraits_Custom_CustomDataTrait;
9
10 public function tearDown() {
11 $this->quickCleanup(['civicrm_saved_search']);
12 }
13
14 /**
15 * Test message upgrade process.
16 */
17 public function testMessageTemplateUpgrade() {
18 $workFlowID = civicrm_api3('OptionValue', 'getvalue', ['return' => 'id', 'name' => 'membership_online_receipt', 'options' => ['limit' => 1, 'sort' => 'id DESC']]);
19
20 $templates = $this->callAPISuccess('MessageTemplate', 'get', ['workflow_id' => $workFlowID])['values'];
21 foreach ($templates as $template) {
22 $originalText = $template['msg_text'];
23 $this->callAPISuccess('MessageTemplate', 'create', ['msg_text' => 'great what a cool member you are', 'id' => $template['id']]);
24 $msg_text = $this->callAPISuccessGetValue('MessageTemplate', ['id' => $template['id'], 'return' => 'msg_text']);
25 $this->assertEquals('great what a cool member you are', $msg_text);
26 }
27 $messageTemplateObject = new CRM_Upgrade_Incremental_MessageTemplates('5.4.alpha1');
28 $messageTemplateObject->updateTemplates();
29
30 foreach ($templates as $template) {
31 $msg_text = $this->callAPISuccessGetValue('MessageTemplate', ['id' => $template['id'], 'return' => 'msg_text']);
32 $this->assertContains('{assign var="greeting" value="{contact.email_greeting}"}{if $greeting}{$greeting},{/if}', $msg_text);
33 if ($msg_text !== $originalText) {
34 // Reset value for future tests.
35 $this->callAPISuccess('MessageTemplate', 'create', ['msg_text' => $originalText, 'id' => $template['id']]);
36 }
37 }
38 }
39
40 /**
41 * Test message upgrade process only edits the default if the template is customised.
42 */
43 public function testMessageTemplateUpgradeAlreadyCustomised() {
44 $workFlowID = civicrm_api3('OptionValue', 'getvalue', ['return' => 'id', 'name' => 'membership_online_receipt', 'options' => ['limit' => 1, 'sort' => 'id DESC']]);
45
46 $templates = $this->callAPISuccess('MessageTemplate', 'get', ['workflow_id' => $workFlowID])['values'];
47 foreach ($templates as $template) {
48 if ($template['is_reserved']) {
49 $originalText = $template['msg_text'];
50 $this->callAPISuccess('MessageTemplate', 'create', ['msg_text' => 'great what a cool member you are', 'id' => $template['id']]);
51 }
52 else {
53 $this->callAPISuccess('MessageTemplate', 'create', ['msg_text' => 'great what a silly sausage you are', 'id' => $template['id']]);
54 }
55 }
56 $messageTemplateObject = new CRM_Upgrade_Incremental_MessageTemplates('5.4.alpha1');
57 $messageTemplateObject->updateTemplates();
58
59 foreach ($templates as $template) {
60 $msg_text = $this->callAPISuccessGetValue('MessageTemplate', ['id' => $template['id'], 'return' => 'msg_text']);
61 if ($template['is_reserved']) {
62 $this->assertContains('{assign var="greeting" value="{contact.email_greeting}"}{if $greeting}{$greeting},{/if}', $msg_text);
63 }
64 else {
65 $this->assertEquals('great what a silly sausage you are', $msg_text);
66 }
67
68 if ($msg_text !== $originalText) {
69 // Reset value for future tests.
70 $this->callAPISuccess('MessageTemplate', 'create', ['msg_text' => $originalText, 'id' => $template['id']]);
71 }
72 }
73 }
74
75 /**
76 * Test function for messages on upgrade.
77 */
78 public function testMessageTemplateGetUpgradeMessages() {
79 $messageTemplateObject = new CRM_Upgrade_Incremental_MessageTemplates('5.4.alpha1');
80 $messages = $messageTemplateObject->getUpgradeMessages();
81 $this->assertEquals([
82 'Memberships - Receipt (on-line)' => 'Use email greeting at top where available',
83 'Contributions - Receipt (on-line)' => 'Use email greeting at top where available',
84 'Events - Registration Confirmation and Receipt (on-line)' => 'Use email greeting at top where available',
85 ], $messages);
86 }
87
88 /**
89 * Test converting a datepicker field.
90 */
91 public function testSmartGroupDatePickerConversion() {
92 $this->callAPISuccess('SavedSearch', 'create', [
93 'form_values' => [
94 ['grant_application_received_date_high', '=', '01/20/2019'],
95 ['grant_due_date_low', '=', '01/22/2019'],
96 ],
97 ]);
98 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
99 $smartGroupConversionObject->updateGroups([
100 'datepickerConversion' => [
101 'grant_application_received_date',
102 'grant_decision_date',
103 'grant_money_transfer_date',
104 'grant_due_date',
105 ],
106 ]);
107 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
108 $this->assertEquals('grant_application_received_date_high', $savedSearch['form_values'][0][0]);
109 $this->assertEquals('2019-01-20 23:59:59', $savedSearch['form_values'][0][2]);
110 $this->assertEquals('grant_due_date_low', $savedSearch['form_values'][1][0]);
111 $this->assertEquals('2019-01-22 00:00:00', $savedSearch['form_values'][1][2]);
112 $hasRelative = FALSE;
113 foreach ($savedSearch['form_values'] as $form_value) {
114 if ($form_value[0] === 'grant_due_date_relative') {
115 $hasRelative = TRUE;
116 }
117 }
118 $this->assertEquals(TRUE, $hasRelative);
119 }
120
121 /**
122 * Test Multiple Relative Date conversions
123 */
124 public function testSmartGroupMultipleRelatvieDateConversions() {
125 $this->callAPISuccess('SavedSearch', 'create', [
126 'form_values' => [
127 ['membership_join_date_low', '=', '20190903000000'],
128 ['membership_join_date_high', '=', '20190903235959'],
129 ['membership_start_date_low', '=' , '20190901000000'],
130 ['membership_start_date_high', '=', '20190907235959'],
131 ['membership_end_date_low', '=', '20190901000000'],
132 ['membership_end_date_high', '=', '20190907235959'],
133 'relative_dates' => [
134 'member_join' => 'this.day',
135 'member_start' => 'this.week',
136 'member_end' => 'this.week',
137 ],
138 ],
139 ]);
140 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
141 $smartGroupConversionObject->updateGroups([
142 'datepickerConversion' => [
143 'membership_join_date',
144 'membership_start_date',
145 'membership_end_date',
146 ],
147 ]);
148 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
149 $this->assertContains('6', array_keys($savedSearch['form_values']));
150 $this->assertEquals('membership_join_date_relative', $savedSearch['form_values'][6][0]);
151 $this->assertEquals('this.day', $savedSearch['form_values'][6][2]);
152 $this->assertContains('7', array_keys($savedSearch['form_values']));
153 $this->assertEquals('membership_start_date_relative', $savedSearch['form_values'][7][0]);
154 $this->assertEquals('this.week', $savedSearch['form_values'][7][2]);
155 $this->assertContains('8', array_keys($savedSearch['form_values']));
156 $this->assertEquals('membership_end_date_relative', $savedSearch['form_values'][8][0]);
157 $this->assertEquals('this.week', $savedSearch['form_values'][8][2]);
158 }
159
160 /**
161 * Test upgrading multiple Event smart groups of different formats
162 */
163 public function testMultipleEventSmartGroupDateConversions() {
164 $this->callAPISuccess('SavedSearch', 'create', [
165 'form_values' => [
166 ['event_start_date_low', '=', '20191001000000'],
167 ['event_end_date_high', '=', '20191031235959'],
168 'relative_dates' => [
169 'event' => 'this.month',
170 ],
171 ],
172 ]);
173 $this->callAPISuccess('SavedSearch', 'create', [
174 'form_values' => [
175 ['event_start_date_low', '=', '20191001000000'],
176 ],
177 ]);
178 $this->callAPISuccess('SavedSearch', 'create', [
179 'form_values' => [
180 'event_start_date_low' => '20191001000000',
181 'event_end_date_high' => '20191031235959',
182 'event_relative' => 'this.month',
183 ],
184 ]);
185 $this->callAPISuccess('SavedSearch', 'create', [
186 'form_values' => [
187 'event_start_date_low' => '10/01/2019',
188 'event_end_date_high' => '',
189 'event_relative' => '0',
190 ],
191 ]);
192 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
193 $smartGroupConversionObject->renameFields([
194 ['old' => 'event_start_date_low', 'new' => 'event_low'],
195 ['old' => 'event_end_date_high', 'new' => 'event_high'],
196 ]);
197 $smartGroupConversionObject->updateGroups([
198 'datepickerConversion' => [
199 'event',
200 ],
201 ]);
202 $expectedResults = [
203 1 => [
204 'relative_dates' => [],
205 2 => ['event_relative', '=', 'this.month'],
206 ],
207 2 => [
208 0 => ['event_low', '=', '2019-10-01 00:00:00'],
209 1 => ['event_relative', '=', 0],
210 ],
211 3 => [
212 'event_relative' => 'this.month',
213 ],
214 4 => [
215 'event_relative' => 0,
216 'event_low' => '2019-10-01 00:00:00',
217 ],
218 ];
219 $savedSearches = $this->callAPISuccess('SavedSearch', 'get', []);
220 foreach ($savedSearches['values'] as $id => $savedSearch) {
221 $this->assertEquals($expectedResults[$id], $savedSearch['form_values']);
222 }
223 }
224
225 /**
226 * Test Log Date conversion
227 */
228 public function testLogDateConversion() {
229 // Create two sets of searches one set for added by and one for modified by
230 // Each set contains a relative search on this.month and a specific date search low
231 $this->callAPISuccess('SavedSearch', 'create', [
232 'form_values' => [
233 ['log_date', '=', 1],
234 ['log_date_low', '=', '20191001000000'],
235 ['log_date_high', '=', '20191031235959'],
236 'relative_dates' => [
237 'log' => 'this.month',
238 ],
239 ],
240 ]);
241 $this->callAPISuccess('SavedSearch', 'create', [
242 'form_values' => [
243 ['log_date', '=', 1],
244 ['log_date_low', '=', '20191001000000'],
245 ],
246 ]);
247 $this->callAPISuccess('SavedSearch', 'create', [
248 'form_values' => [
249 ['log_date', '=', 2],
250 ['log_date_low', '=', '20191001000000'],
251 ['log_date_high', '=', '20191031235959'],
252 'relative_dates' => [
253 'log' => 'this.month',
254 ],
255 ],
256 ]);
257 $this->callAPISuccess('SavedSearch', 'create', [
258 'form_values' => [
259 ['log_date', '=', 2],
260 ['log_date_low', '=', '20191001000000'],
261 ],
262 ]);
263 // On the original search form you didn't need to select the log_date radio
264 // If it wasn't selected it defaulted to created_date filtering.
265 $this->callAPISuccess('SavedSearch', 'create', [
266 'form_values' => [
267 ['log_date_low', '=', '20191001000000'],
268 ['log_date_high', '=', '20191031235959'],
269 'relative_dates' => [
270 'log' => 'this.month',
271 ],
272 ],
273 ]);
274 $this->callAPISuccess('SavedSearch', 'create', [
275 'form_values' => [
276 ['log_date_low', '=', '20191001000000'],
277 ],
278 ]);
279 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
280 $smartGroupConversionObject->renameLogFields();
281 $smartGroupConversionObject->updateGroups([
282 'datepickerConversion' => [
283 'created_date',
284 'modified_date',
285 ],
286 ]);
287 $savedSearhes = $this->callAPISuccess('SavedSearch', 'get', []);
288 $expectedResults = [
289 1 => [
290 0 => ['log_date', '=', 1],
291 'relative_dates' => [],
292 3 => ['created_date_relative', '=', 'this.month'],
293 ],
294 2 => [
295 0 => ['log_date', '=', 1],
296 1 => ['created_date_low', '=', '2019-10-01 00:00:00'],
297 2 => ['created_date_relative', '=', 0],
298 ],
299 3 => [
300 0 => ['log_date', '=', 2],
301 'relative_dates' => [],
302 3 => ['modified_date_relative', '=', 'this.month'],
303 ],
304 4 => [
305 0 => ['log_date', '=', 2],
306 1 => ['modified_date_low', '=', '2019-10-01 00:00:00'],
307 2 => ['modified_date_relative', '=', 0],
308 ],
309 5 => [
310 'relative_dates' => [],
311 2 => ['created_date_relative', '=', 'this.month'],
312 ],
313 6 => [
314 0 => ['created_date_low', '=', '2019-10-01 00:00:00'],
315 1 => ['created_date_relative', '=', 0],
316 ],
317 ];
318 }
319
320 /**
321 * Test converting relationship fields
322 */
323 public function testSmartGroupRelationshipDateConversions() {
324 $this->callAPISuccess('SavedSearch', 'create', [
325 'form_values' => [
326 ['relationship_start_date_low', '=', '20191001000000'],
327 ['relationship_start_date_high', '=', '20191031235959'],
328 ['relationship_end_date_low', '=', '20191001000000'],
329 ['relationship_end_date_high', '=', '20191031235959'],
330 'relative_dates' => [
331 'relation_start' => 'this.month',
332 'relation_end' => 'this.month',
333 ],
334 ],
335 ]);
336 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
337 $smartGroupConversionObject->updateGroups([
338 'datepickerConversion' => [
339 'relationship_start_date',
340 'relationship_end_date',
341 ],
342 ]);
343 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
344 $this->assertEquals([], $savedSearch['form_values']['relative_dates']);
345 $this->assertEquals(['relationship_start_date_relative', '=', 'this.month'], $savedSearch['form_values'][4]);
346 $this->assertEquals(['relationship_end_date_relative', '=', 'this.month'], $savedSearch['form_values'][5]);
347 }
348
349 /**
350 * Test convert custom saved search
351 */
352 public function testSmartGroupCustomDateRangeSearch() {
353 $this->entity = 'Contact';
354 $this->createCustomGroupWithFieldOfType([], 'date');
355 $dateCustomFieldName = $this->getCustomFieldName('date');
356 $this->callAPISuccess('SavedSearch', 'create', [
357 'form_values' => [
358 [$dateCustomFieldName . '_relative', '=', 0],
359 [$dateCustomFieldName, '=', ['BETWEEN' => ['20191001000000', '20191031235959']]],
360 ],
361 ]);
362 $this->callAPISuccess('SavedSearch', 'create', [
363 'form_values' => [
364 [$dateCustomFieldName . '_relative', '=', 0],
365 [$dateCustomFieldName, '=', ['>=' => '20191001000000']],
366 ],
367 ]);
368 $this->callAPISuccess('SavedSearch', 'create', [
369 'form_values' => [
370 [$dateCustomFieldName . '_relative', '=', 0],
371 [$dateCustomFieldName, '=', ['<=' => '20191031235959']],
372 ],
373 ]);
374 $this->callAPISuccess('SavedSearch', 'create', [
375 'form_values' => [
376 [$dateCustomFieldName . '_relative', '=', 'this.month'],
377 ],
378 ]);
379 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
380 $smartGroupConversionObject->convertCustomSmartGroups();
381 $expectedResults = [
382 1 => [
383 0 => [$dateCustomFieldName . '_relative', '=', 0],
384 2 => [$dateCustomFieldName . '_low', '=', '2019-10-01 00:00:00'],
385 3 => [$dateCustomFieldName . '_high', '=', '2019-10-31 23:59:59'],
386 ],
387 2 => [
388 0 => [$dateCustomFieldName . '_relative', '=', 0],
389 2 => [$dateCustomFieldName . '_low', '=', '2019-10-01 00:00:00'],
390 ],
391 3 => [
392 0 => [$dateCustomFieldName . '_relative', '=', 0],
393 2 => [$dateCustomFieldName . '_high', '=', '2019-10-31 23:59:59'],
394 ],
395 4 => [
396 0 => [$dateCustomFieldName . '_relative', '=', 'this.month'],
397 ],
398 ];
399 $savedSearches = $this->callAPISuccess('SavedSearch', 'get', []);
400 foreach ($savedSearches['values'] as $id => $savedSearch) {
401 $this->assertEquals($expectedResults[$id], $savedSearch['form_values']);
402 }
403 }
404
405 /**
406 * Test conversion of on hold group.
407 */
408 public function testOnHoldConversion() {
409 $this->callAPISuccess('SavedSearch', 'create', [
410 'form_values' => [
411 ['on_hold', '=', '1'],
412 ],
413 ]);
414 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups('5.11.alpha1');
415 $smartGroupConversionObject->convertEqualsStringToInArray('on_hold');
416 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
417 $this->assertEquals('IN', $savedSearch['form_values'][0][1]);
418 $this->assertEquals(['1'], $savedSearch['form_values'][0][2]);
419
420 }
421
422 /**
423 * Test renaming a field.
424 */
425 public function testRenameField() {
426 $this->callAPISuccess('SavedSearch', 'create', [
427 'form_values' => [
428 ['activity_date_low', '=', '01/22/2019'],
429 ],
430 ]);
431 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
432 $smartGroupConversionObject->renameField('activity_date_low', 'activity_date_time_low');
433 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
434 $this->assertEquals('activity_date_time_low', $savedSearch['form_values'][0][0]);
435 }
436
437 /**
438 * Test renaming multiple fields.
439 *
440 * @throws Exception
441 */
442 public function testRenameFields() {
443 $this->callAPISuccess('SavedSearch', 'create', [
444 'form_values' => [
445 ['activity_date_low', '=', '01/22/2019'],
446 ['activity_date_relative', '=', 0],
447 ],
448 ]);
449 $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
450 $smartGroupConversionObject->renameFields([
451 ['old' => 'activity_date_low', 'new' => 'activity_date_time_low'],
452 ['old' => 'activity_date_relative', 'new' => 'activity_date_time_relative'],
453 ]);
454 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
455 $this->assertEquals('activity_date_time_low', $savedSearch['form_values'][0][0]);
456 $this->assertEquals('activity_date_time_relative', $savedSearch['form_values'][1][0]);
457 }
458
459 /**
460 * Test that a mis-saved variable in 'contribute settings' can be converted to a
461 * 'proper' setting.
462 */
463 public function testConvertUpgradeContributeSettings() {
464 $setting = [
465 'deferred_revenue_enabled' => 1,
466 'invoice_prefix' => 'G_',
467 'credit_notes_prefix' => 'XX_',
468 'due_date' => '20',
469 'due_date_period' => 'weeks',
470 'notes' => '<p>Give me money</p>',
471 'tax_term' => 'Extortion',
472 'tax_display_settings' => 'Exclusive',
473 ];
474 CRM_Core_DAO::executeQuery("INSERT INTO civicrm_setting (name, domain_id, value)
475 VALUES ('contribution_invoice_settings', 1, '" . serialize($setting) . "')");
476 CRM_Upgrade_Incremental_Base::updateContributeSettings(NULL, 5.1);
477 $this->assertEquals(1, Civi::settings()->get('deferred_revenue_enabled'));
478 $this->assertEquals('G_', Civi::settings()->get('invoice_prefix'));
479 $this->assertEquals('XX_', Civi::settings()->get('credit_notes_prefix'));
480 $this->assertEquals('20', Civi::settings()->get('invoice_due_date'));
481 $this->assertEquals('weeks', Civi::settings()->get('invoice_due_date_period'));
482 $this->assertEquals('<p>Give me money</p>', Civi::settings()->get('invoice_notes'));
483 $this->assertEquals('Extortion', Civi::settings()->get('tax_term'));
484 $this->assertEquals('Exclusive', Civi::settings()->get('tax_display_settings'));
485 }
486
487 /**
488 * dev/core#1405 Test fixing option groups with spaces in the name
489 */
490 public function testFixOptionGroupName() {
491 $name = 'This is a test Name';
492 $fixedName = CRM_Utils_String::titleToVar(strtolower($name));
493 $optionGroup = $this->callAPISuccess('OptionGroup', 'create', [
494 'title' => 'Test Option Group',
495 'name' => $name,
496 ]);
497 // API is hardened to strip the spaces to lets re-add in now
498 CRM_Core_DAO::executeQuery("UPDATE civicrm_option_group SET name = %1 WHERE id = %2", [
499 1 => [$name, 'String'],
500 2 => [$optionGroup['id'], 'Positive'],
501 ]);
502 $preUpgrade = $this->callAPISuccess('OptionGroup', 'getsingle', ['id' => $optionGroup['id']]);
503 $this->assertEquals($name, $preUpgrade['name']);
504 CRM_Upgrade_Incremental_php_FiveTwentyOne::fixOptionGroupName();
505 $postUpgrade = $this->callAPISuccess('OptionGroup', 'getsingle', ['id' => $optionGroup['id']]);
506 $this->assertEquals($fixedName, $postUpgrade['name'], 'Ensure that the spaces have been removed from OptionGroup name');
507 $this->assertEquals($postUpgrade['name'], $optionGroup['values'][$optionGroup['id']]['name'], 'Ensure that the fixed name matches what the API would produce');
508 $this->callAPISuccess('OptionGroup', 'delete', ['id' => $optionGroup['id']]);
509 }
510
511 /**
512 * Test that if there is an option group name as the same as the proposed fix name that doesn't cause a hard fail in the upgrade
513 */
514 public function testFixOptionGroupNameWithFixedNameInDatabase() {
515 $name = 'This is a test Name';
516 $fixedName = CRM_Utils_String::titleToVar(strtolower($name));
517 $optionGroup = $this->callAPISuccess('OptionGroup', 'create', [
518 'title' => 'Test Option Group',
519 'name' => $name,
520 ]);
521 // API is hardened to strip the spaces to lets re-add in now
522 CRM_Core_DAO::executeQuery("UPDATE civicrm_option_group SET name = %1 WHERE id = %2", [
523 1 => [$name, 'String'],
524 2 => [$optionGroup['id'], 'Positive'],
525 ]);
526 $optionGroup2 = $this->callAPISuccess('OptionGroup', 'create', [
527 'title' => 'Test Option Group 2',
528 'name' => $name,
529 ]);
530 $preUpgrade = $this->callAPISuccess('OptionGroup', 'getsingle', ['id' => $optionGroup['id']]);
531 $this->assertEquals($name, $preUpgrade['name']);
532 $preUpgrade = $this->callAPISuccess('OptionGroup', 'getsingle', ['id' => $optionGroup2['id']]);
533 $this->assertEquals($fixedName, $preUpgrade['name']);
534 CRM_Upgrade_Incremental_php_FiveTwentyOne::fixOptionGroupName();
535 $this->callAPISuccess('OptionGroup', 'delete', ['id' => $optionGroup['id']]);
536 $this->callAPISuccess('OptionGroup', 'delete', ['id' => $optionGroup2['id']]);
537 }
538
539 /**
540 * Test conversion between jcalendar and datepicker in reports
541 */
542 public function testReportFormConvertDatePicker() {
543 $report = $this->callAPISuccess('ReportInstance', 'create', [
544 'report_id' => 'contribute/detail',
545 'form_values' => [
546 'fields' => [
547 'sort_name' => 1,
548 'email' => 1,
549 'phone' => 1,
550 'financial_type_id' => 1,
551 'receive_date' => 1,
552 'total_amount' => 1,
553 'country_id' => 1,
554 ],
555 'sort_name_op' => 'has',
556 'sort_name_value' => '',
557 'id_min' => '',
558 'id_max' => '',
559 'id_op' => 'lte',
560 'id_value' => '',
561 'contact_type_op' => 'in',
562 'contact_type_value' => [],
563 'contact_sub_type_op' => 'in',
564 'contact_sub_type_value' => [],
565 'is_deleted_op' => 'eq',
566 'is_deleted_value' => 0,
567 'preferred_language_op' => 'in',
568 'preferred_language_value' => [],
569 'do_not_email_op' => 'eq',
570 'do_not_email_value' => '',
571 'do_not_phone_op' => 'eq',
572 'do_not_phone_value' => '',
573 'do_not_mail_op' => 'eq',
574 'do_not_mail_value' => '',
575 'do_not_sms_op' => 'eq',
576 'do_not_sms_value' => '',
577 'is_opt_out_op' => 'eq',
578 'is_opt_out_value' => '',
579 'first_name_op' => 'has',
580 'first_name_value' => '',
581 'prefix_id_op' => 'in',
582 'prefix_id_value' => [],
583 'suffix_id_op' => 'in',
584 'suffix_id_value' => [],
585 'gender_id_op' => 'in',
586 'gender_id_value' => [],
587 'birth_date_relative' => '',
588 'birth_date_from' => '',
589 'birth_date_to' => '',
590 'is_deceased_op' => 'eq',
591 'is_deceased_value' => '',
592 'contribution_or_soft_op' => 'eq',
593 'contribution_or_soft_value' => 'contributions_only',
594 'receive_date_relative' => 0,
595 'receive_date_from' => '11/01/1991',
596 'receive_date_to' => '',
597 'thankyou_date_relative' => '',
598 'thankyou_date_from' => '',
599 'thankyou_date_to' => '',
600 'contribution_source_op' => 'has',
601 'contribution_source_value' => '',
602 'currency_op' => 'in',
603 'currency_value' => [],
604 'non_deductible_amount_min' => '',
605 'non_deductible_amount_max' => '',
606 'non_deductible_amount_op' => 'lte',
607 'non_deductible_amount_value' => '',
608 'financial_type_id_op' => 'in',
609 'financial_type_id_value' => [],
610 'contribution_page_id_op' => 'in',
611 'contribution_page_id_value' => [],
612 'payment_instrument_id_op' => 'in',
613 'payment_instrument_id_value' => [],
614 'contribution_status_id_op' => 'in',
615 'contribution_status_id_value' => [0 => 1],
616 'total_amount_min' => '',
617 'total_amount_max' => '',
618 'total_amount_op' => 'lte',
619 'total_amount_value' => '',
620 'cancel_date_relative' => '',
621 'cancel_date_from' => '',
622 'cancel_date_to' => '',
623 'cancel_reason_op' => 'has',
624 'cancel_reason_value' => '',
625 'soft_credit_type_id_op' => 'in',
626 'soft_credit_type_id_value' => [],
627 'card_type_id_op' => 'in',
628 'card_type_id_value' => [],
629 'ordinality_op' => 'in',
630 'ordinality_value' => [],
631 'note_value' => '',
632 'street_address_op' => 'has',
633 'street_address_value' => '',
634 'postal_code_op' => 'has',
635 'postal_code_value' => '',
636 'city_op' => 'has',
637 'city_value' => '',
638 'country_id_op' => 'in',
639 'country_id_value' => [],
640 'state_province_id_op' => 'in',
641 'state_province_id_value' => [],
642 'county_id_op' => 'in',
643 'county_id_value' => [],
644 'tagid_op' => 'in',
645 'tagid_value' => [],
646 'gid_op' => 'in',
647 'gid_value' => [],
648 'group_bys' => ['contribution_id' => 1],
649 'order_bys' => [
650 1 => [
651 'column' => 'sort_name',
652 'order' => 'ASC',
653 ],
654 ],
655 'description' => 'Lists specific contributions by criteria including contact, time period, contribution type, contributor location, etc. Contribution summary report points to this report for contribution details.',
656 'email_subject' => '',
657 'email_to' => '',
658 'email_cc' => '',
659 'row_count' => '',
660 'view_mode' => 'criteria',
661 'cache_minutes' => 60,
662 'permission' => 'access CiviContribute',
663 'parent_id' => '',
664 'radio_ts' => '',
665 'groups' => '',
666 'report_id' => 'contribute/detail',
667 ],
668 'title' => 'test Report',
669 ]);
670 CRM_Upgrade_Incremental_php_FiveTwentyFive::convertReportsJcalendarToDatePicker();
671 $reportGet = $this->callAPISuccess('ReportInstance', 'getsingle', ['id' => $report['id']]);
672 $formValues = unserialize($reportGet['form_values']);
673 $this->assertEquals('1991-11-01 00:00:00', $formValues['receive_date_from']);
674 }
675
676 public function testUpdateContactTypeNameField() {
677 CRM_Core_DAO::executeQuery("INSERT INTO civicrm_contact_type (name,label,parent_id, is_active) VALUES ('', 'Test Contact Type', 1, 1)");
678 CRM_Upgrade_Incremental_php_FiveTwentyEight::populateMissingContactTypeName();
679 $contactType = $this->callAPISuccess('ContactType', 'getsingle', ['label' => 'Test Contact Type']);
680 $this->assertNotEmpty($contactType['name']);
681 $this->callAPISuccess('ContactType', 'delete', ['id' => $contactType['id']]);
682 }
683
684 }