3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Test APIv3 civicrm_contribute_* functions
31 * @package CiviCRM_APIv3
32 * @subpackage API_Contribution
35 class api_v3_PaymentTest
extends CiviUnitTestCase
{
37 protected $_individualId;
39 protected $_financialTypeId = 1;
41 protected $_apiversion;
48 public function setUp() {
51 $this->_apiversion
= 3;
52 $this->_individualId
= $this->individualCreate();
53 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= [];
57 * Clean up after each test.
59 public function tearDown() {
60 $this->quickCleanUpFinancialEntities();
61 $this->quickCleanup(['civicrm_uf_match']);
62 unset(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
);
66 * Test Get Payment api.
68 public function testGetPayment() {
70 'contact_id' => $this->_individualId
,
71 'receive_date' => '2010-01-20',
72 'total_amount' => 100.00,
73 'financial_type_id' => $this->_financialTypeId
,
75 'contribution_status_id' => 1,
77 $contribution = $this->callAPISuccess('contribution', 'create', $p);
80 'contribution_id' => $contribution['id'],
81 'check_permissions' => TRUE,
83 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['access CiviCRM', 'administer CiviCRM'];
84 $payment = $this->callAPIFailure('payment', 'get', $params, 'API permission check failed for Payment/get call; insufficient permission: require access CiviCRM and access CiviContribute');
86 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviContribute');
87 $payment = $this->callAPISuccess('payment', 'get', $params);
89 $payment = $this->callAPIAndDocument('payment', 'get', $params, __FUNCTION__
, __FILE__
);
90 $this->assertEquals(1, $payment['count']);
93 $contribution['id'] => [
94 'total_amount' => 100,
96 'trxn_date' => '2010-01-20 00:00:00',
97 'contribution_id' => $contribution['id'],
101 $this->checkPaymentResult($payment, $expectedResult);
102 $this->callAPISuccess('Contribution', 'Delete', [
103 'id' => $contribution['id'],
108 * Test email receipt for partial payment.
110 public function testPaymentEmailReceipt() {
111 $mut = new CiviMailUtils($this);
112 list($lineItems, $contribution) = $this->createParticipantWithContribution();
113 $event = $this->callAPISuccess('Event', 'get', []);
114 $this->addLocationToEvent($event['id']);
116 'contribution_id' => $contribution['id'],
117 'total_amount' => 50,
118 'check_number' => '345',
119 'trxn_date' => '2018-08-13 17:57:56',
121 $payment = $this->callAPISuccess('payment', 'create', $params);
122 $this->checkPaymentResult($payment, [
124 'from_financial_account_id' => 7,
125 'to_financial_account_id' => 6,
126 'total_amount' => 50,
132 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
133 $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
136 'Total Fees: $ 300.00',
137 'This Payment Amount: $ 50.00',
138 //150 was paid in the 1st payment.
139 'Balance Owed: $ 100.00',
140 'Event Information and Location',
143 'Transaction Date: August 13th, 2018 5:57 PM',
148 $mut->clearMessages();
152 * Test email receipt for partial payment.
154 public function testPaymentEmailReceiptFullyPaid() {
155 $mut = new CiviMailUtils($this);
156 list($lineItems, $contribution) = $this->createParticipantWithContribution();
159 'contribution_id' => $contribution['id'],
160 'total_amount' => 150,
162 $payment = $this->callAPISuccess('payment', 'create', $params);
164 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
165 $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
168 'A payment has been received.',
169 'Total Fees: $ 300.00',
170 'This Payment Amount: $ 150.00',
171 'Balance Owed: $ 0.00',
172 'Thank you for completing payment.',
175 $mut->clearMessages();
179 * Test email receipt for partial payment.
181 * @dataProvider getThousandSeparators
183 * @param string $thousandSeparator
185 public function testRefundEmailReceipt($thousandSeparator) {
186 $this->setCurrencySeparators($thousandSeparator);
187 $decimalSeparator = ($thousandSeparator === ',' ?
'.' : ',');
188 $mut = new CiviMailUtils($this);
189 list($lineItems, $contribution) = $this->createParticipantWithContribution();
190 $this->callAPISuccess('payment', 'create', [
191 'contribution_id' => $contribution['id'],
192 'total_amount' => 50,
193 'check_number' => '345',
194 'trxn_date' => '2018-08-13 17:57:56',
197 $payment = $this->callAPISuccess('payment', 'create', [
198 'contribution_id' => $contribution['id'],
199 'total_amount' => -30,
200 'trxn_date' => '2018-11-13 12:01:56',
201 'sequential' => TRUE,
205 'from_financial_account_id' => 7,
206 'to_financial_account_id' => 6,
207 'total_amount' => -30,
208 'status_id' => CRM_Core_PseudoConstant
::getKey('CRM_Core_BAO_FinancialTrxn', 'status_id', 'Refunded'),
211 foreach ($expected as $key => $value) {
212 $this->assertEquals($expected[$key], $payment[$key], 'mismatch on key ' . $key);
215 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
216 $mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']);
219 'A refund has been issued based on changes in your registration selections.',
220 'Total Fees: $ 300' . $decimalSeparator . '00',
221 'Refund Amount: $ -30' . $decimalSeparator . '00',
222 'Event Information and Location',
224 'Transaction Date: November 13th, 2018 12:01 PM',
225 'You Paid: $ 170' . $decimalSeparator . '00',
228 $mut->clearMessages();
232 * Test create payment api with no line item in params
234 public function testCreatePaymentNoLineItems() {
235 list($lineItems, $contribution) = $this->createParticipantWithContribution();
237 //Create partial payment
239 'contribution_id' => $contribution['id'],
240 'total_amount' => 50,
242 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
);
245 'from_financial_account_id' => 7,
246 'to_financial_account_id' => 6,
247 'total_amount' => 50,
252 $this->checkPaymentResult($payment, $expectedResult);
254 // Check entity financial trxn created properly
256 'entity_id' => $contribution['id'],
257 'entity_table' => 'civicrm_contribution',
258 'financial_trxn_id' => $payment['id'],
261 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
263 $this->assertEquals($eft['values'][$eft['id']]['amount'], 50);
266 'entity_table' => 'civicrm_financial_item',
267 'financial_trxn_id' => $payment['id'],
269 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
270 $amounts = [33.33, 16.67];
271 foreach ($eft['values'] as $value) {
272 $this->assertEquals($value['amount'], array_pop($amounts));
275 // Now create payment to complete total amount of contribution
277 'contribution_id' => $contribution['id'],
278 'total_amount' => 100,
280 $payment = $this->callAPISuccess('payment', 'create', $params);
283 'from_financial_account_id' => 7,
284 'to_financial_account_id' => 6,
285 'total_amount' => 100,
290 $this->checkPaymentResult($payment, $expectedResult);
292 'entity_table' => 'civicrm_financial_item',
293 'financial_trxn_id' => $payment['id'],
295 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
296 $amounts = [66.67, 33.33];
297 foreach ($eft['values'] as $value) {
298 $this->assertEquals($value['amount'], array_pop($amounts));
300 // Check contribution for completed status
301 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
303 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
304 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 300.00);
305 $paymentParticipant = [
306 'contribution_id' => $contribution['id'],
308 $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $paymentParticipant);
309 $participant = $this->callAPISuccess('participant', 'get', ['id' => $participantPayment['participant_id']]);
310 $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Registered');
311 $this->callAPISuccess('Contribution', 'Delete', [
312 'id' => $contribution['id'],
317 * Function to assert db values
319 public function checkPaymentResult($payment, $expectedResult) {
320 foreach ($expectedResult[$payment['id']] as $key => $value) {
321 $this->assertEquals($payment['values'][$payment['id']][$key], $value, 'mismatch on ' . $key);
326 * Test create payment api with line item in params
328 public function testCreatePaymentLineItems() {
329 list($lineItems, $contribution) = $this->createParticipantWithContribution();
330 $lineItems = $this->callAPISuccess('LineItem', 'get', ['contribution_id' => $contribution['id']]);
332 //Create partial payment by passing line item array is params
334 'contribution_id' => $contribution['id'],
335 'total_amount' => 50,
338 foreach ($lineItems['values'] as $id => $ignore) {
339 $params['line_item'][] = [$id => array_pop($amounts)];
341 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
, 'Payment with line item', 'CreatePaymentWithLineItems');
344 'from_financial_account_id' => 7,
345 'to_financial_account_id' => 6,
346 'total_amount' => 50,
351 $this->checkPaymentResult($payment, $expectedResult);
353 // Check entity financial trxn created properly
355 'entity_id' => $contribution['id'],
356 'entity_table' => 'civicrm_contribution',
357 'financial_trxn_id' => $payment['id'],
360 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
362 $this->assertEquals($eft['values'][$eft['id']]['amount'], 50);
365 'entity_table' => 'civicrm_financial_item',
366 'financial_trxn_id' => $payment['id'],
368 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
370 foreach ($eft['values'] as $value) {
371 $this->assertEquals($value['amount'], array_pop($amounts));
374 // Now create payment to complete total amount of contribution
376 'contribution_id' => $contribution['id'],
377 'total_amount' => 100,
380 foreach ($lineItems['values'] as $id => $ignore) {
381 $params['line_item'][] = [$id => array_pop($amounts)];
383 $payment = $this->callAPISuccess('payment', 'create', $params);
386 'from_financial_account_id' => 7,
387 'to_financial_account_id' => 6,
388 'total_amount' => 100,
393 $this->checkPaymentResult($payment, $expectedResult);
395 'entity_table' => 'civicrm_financial_item',
396 'financial_trxn_id' => $payment['id'],
398 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
400 foreach ($eft['values'] as $value) {
401 $this->assertEquals($value['amount'], array_pop($amounts));
403 // Check contribution for completed status
404 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
406 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
407 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 300.00);
408 $paymentParticipant = [
409 'contribution_id' => $contribution['id'],
411 $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $paymentParticipant);
412 $participant = $this->callAPISuccess('participant', 'get', ['id' => $participantPayment['participant_id']]);
413 $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Registered');
414 $this->callAPISuccess('Contribution', 'Delete', [
415 'id' => $contribution['id'],
420 * Test cancel payment api
422 public function testCancelPayment() {
423 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute'];
424 list($lineItems, $contribution) = $this->createParticipantWithContribution();
427 'contribution_id' => $contribution['id'],
430 $payment = $this->callAPISuccess('payment', 'get', $params);
431 $this->assertEquals(1, $payment['count']);
434 'id' => $payment['id'],
435 'check_permissions' => TRUE,
437 $payment = $this->callAPIFailure('payment', 'cancel', $cancelParams, 'API permission check failed for Payment/cancel call; insufficient permission: require access CiviCRM and access CiviContribute and edit contributions');
439 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'edit contributions');
441 $this->callAPIAndDocument('payment', 'cancel', $cancelParams, __FUNCTION__
, __FILE__
);
443 $payment = $this->callAPISuccess('payment', 'get', $params);
444 $this->assertEquals(2, $payment['count']);
445 $amounts = [-150.00, 150.00];
446 foreach ($payment['values'] as $value) {
447 $this->assertEquals($value['total_amount'], array_pop($amounts), 'Mismatch total amount');
450 $this->callAPISuccess('Contribution', 'Delete', [
451 'id' => $contribution['id'],
456 * Test delete payment api
458 public function testDeletePayment() {
459 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute'];
460 list($lineItems, $contribution) = $this->createParticipantWithContribution();
463 'contribution_id' => $contribution['id'],
466 $payment = $this->callAPISuccess('payment', 'get', $params);
467 $this->assertEquals(1, $payment['count']);
470 'id' => $payment['id'],
471 'check_permissions' => TRUE,
473 $payment = $this->callAPIFailure('payment', 'delete', $deleteParams, 'API permission check failed for Payment/delete call; insufficient permission: require access CiviCRM and access CiviContribute and delete in CiviContribute');
475 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'delete in CiviContribute');
476 $this->callAPIAndDocument('payment', 'delete', $deleteParams, __FUNCTION__
, __FILE__
);
478 $payment = $this->callAPISuccess('payment', 'get', $params);
479 $this->assertEquals(0, $payment['count']);
481 $this->callAPISuccess('Contribution', 'Delete', [
482 'id' => $contribution['id'],
487 * Test update payment api
489 public function testUpdatePayment() {
490 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute', 'edit contributions'];
491 list($lineItems, $contribution) = $this->createParticipantWithContribution();
493 //Create partial payment by passing line item array is params
495 'contribution_id' => $contribution['id'],
496 'total_amount' => 50,
499 $payment = $this->callAPISuccess('payment', 'create', $params);
502 'from_financial_account_id' => 7,
503 'to_financial_account_id' => 6,
504 'total_amount' => 50,
509 $this->checkPaymentResult($payment, $expectedResult);
512 'entity_table' => 'civicrm_financial_item',
513 'financial_trxn_id' => $payment['id'],
515 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
516 $amounts = [33.33, 16.67];
517 foreach ($eft['values'] as $value) {
518 $this->assertEquals($value['amount'], array_pop($amounts));
520 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute'];
522 // update the amount for payment
524 'contribution_id' => $contribution['id'],
525 'total_amount' => 100,
526 'id' => $payment['id'],
527 'check_permissions' => TRUE,
529 $payment = $this->callAPIFailure('payment', 'create', $params, 'API permission check failed for Payment/create call; insufficient permission: require access CiviCRM and access CiviContribute and edit contributions');
531 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'edit contributions');
532 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
, 'Update Payment', 'UpdatePayment');
534 // Check for proportional cancelled payment against lineitems.
536 'entity_table' => 'civicrm_financial_item',
537 'financial_trxn_id' => $payment['id'] - 1,
540 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $minParams);
541 $amounts = [-33.33, -16.67];
543 foreach ($eft['values'] as $value) {
544 $this->assertEquals($value['amount'], array_pop($amounts));
547 // Check for proportional updated payment against lineitems.
549 'entity_table' => 'civicrm_financial_item',
550 'financial_trxn_id' => $payment['id'],
552 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
553 $amounts = [66.67, 33.33];
554 foreach ($eft['values'] as $value) {
555 $this->assertEquals($value['amount'], array_pop($amounts));
559 'contribution_id' => $contribution['id'],
561 $payment = $this->callAPISuccess('payment', 'get', $params);
562 $amounts = [100.00, -50.00, 50.00, 150.00];
563 foreach ($payment['values'] as $value) {
564 $amount = array_pop($amounts);
565 $this->assertEquals($value['total_amount'], $amount, 'Mismatch total amount');
567 // Check entity financial trxn created properly
569 'entity_id' => $contribution['id'],
570 'entity_table' => 'civicrm_contribution',
571 'financial_trxn_id' => $value['id'],
573 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
574 $this->assertEquals($eft['values'][$eft['id']]['amount'], $amount);
577 $this->callAPISuccess('Contribution', 'Delete', [
578 'id' => $contribution['id'],
583 * Test create payment api for paylater contribution
585 public function testCreatePaymentPayLater() {
586 $this->createLoggedInUser();
587 $contributionParams = [
588 'total_amount' => 100,
590 'contact_id' => $this->_individualId
,
591 'financial_type_id' => 1,
592 'contribution_status_id' => 2,
595 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
596 //add payment for pay later transaction
598 'contribution_id' => $contribution['id'],
599 'total_amount' => 100,
601 $payment = $this->callAPISuccess('Payment', 'create', $params);
604 'from_financial_account_id' => 7,
605 'to_financial_account_id' => 6,
606 'total_amount' => 100,
611 $this->checkPaymentResult($payment, $expectedResult);
612 // Check entity financial trxn created properly
614 'entity_id' => $contribution['id'],
615 'entity_table' => 'civicrm_contribution',
616 'financial_trxn_id' => $payment['id'],
618 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
619 $this->assertEquals($eft['values'][$eft['id']]['amount'], 100);
621 'entity_table' => 'civicrm_financial_item',
622 'financial_trxn_id' => $payment['id'],
624 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
625 $this->assertEquals($eft['values'][$eft['id']]['amount'], 100);
626 // Check contribution for completed status
627 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
628 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
629 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
630 $this->callAPISuccess('Contribution', 'Delete', [
631 'id' => $contribution['id'],
636 * Test create payment api for paylater contribution with partial payment.
638 public function testCreatePaymentPayLaterPartialPayment() {
639 $this->createLoggedInUser();
640 $contributionParams = [
641 'total_amount' => 100,
643 'contact_id' => $this->_individualId
,
644 'financial_type_id' => 1,
645 'contribution_status_id' => 2,
648 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
649 //Create partial payment
651 'contribution_id' => $contribution['id'],
652 'total_amount' => 60,
654 $payment = $this->callAPISuccess('Payment', 'create', $params);
657 'total_amount' => 60,
662 $this->checkPaymentResult($payment, $expectedResult);
663 // Check entity financial trxn created properly
665 'entity_id' => $contribution['id'],
666 'entity_table' => 'civicrm_contribution',
667 'financial_trxn_id' => $payment['id'],
669 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
670 $this->assertEquals($eft['values'][$eft['id']]['amount'], 60);
672 'entity_table' => 'civicrm_financial_item',
673 'financial_trxn_id' => $payment['id'],
675 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
676 $this->assertEquals($eft['values'][$eft['id']]['amount'], 60);
677 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
678 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Partially paid');
679 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
680 //Create full payment
682 'contribution_id' => $contribution['id'],
683 'total_amount' => 40,
685 // Rename the 'completed' status label first to check that we are not using the labels!
686 $this->callAPISuccess('OptionValue', 'get', ['name' => 'Completed', 'option_group_id' => 'contribution_status', 'api.OptionValue.create' => ['label' => 'Unicorn']]);
687 $payment = $this->callAPISuccess('Payment', 'create', $params);
690 'from_financial_account_id' => 7,
691 'to_financial_account_id' => 6,
692 'total_amount' => 40,
697 $this->checkPaymentResult($payment, $expectedResult);
698 // Check entity financial trxn created properly
700 'entity_id' => $contribution['id'],
701 'entity_table' => 'civicrm_contribution',
702 'financial_trxn_id' => $payment['id'],
704 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
705 $this->assertEquals($eft['values'][$eft['id']]['amount'], 40);
707 'entity_table' => 'civicrm_financial_item',
708 'financial_trxn_id' => $payment['id'],
710 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
711 $this->assertEquals($eft['values'][$eft['id']]['amount'], 40);
712 // Check contribution for completed status
713 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
714 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Unicorn');
715 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
716 $this->callAPISuccess('Contribution', 'Delete', [
717 'id' => $contribution['id'],
719 $this->callAPISuccess('OptionValue', 'get', ['name' => 'Completed', 'option_group_id' => 'contribution_status', 'api.OptionValue.create' => ['label' => 'Completed']]);
724 * Add a location to our event.
726 * @param int $eventID
728 protected function addLocationToEvent($eventID) {
730 'name' => 'event place',
731 'street_address' => 'streety street',
732 'location_type_id' => 1,
735 // api requires contact_id - perhaps incorrectly but use add to get past that.
736 $address = CRM_Core_BAO_Address
::add($addressParams);
738 $location = $this->callAPISuccess('LocBlock', 'create', ['address_id' => $address->id
]);
739 $this->callAPISuccess('Event', 'create', [
741 'loc_block_id' => $location['id'],
742 'is_show_location' => TRUE,