From: Coleman Watts Date: Tue, 28 Mar 2023 14:25:01 +0000 (-0400) Subject: BAO - Refactor Address add/create to use writeRecord X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=909e0a63eb2abd8adc5fdfc210bc4a1bb88dbc32;p=civicrm-core.git BAO - Refactor Address add/create to use writeRecord --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index b1971d2add..04e9608983 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -1663,7 +1663,7 @@ LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.cont public static function createAddress($params, $billingLocationTypeID) { [$hasBillingField, $addressParams] = self::getBillingAddressParams($params, $billingLocationTypeID); if ($hasBillingField) { - $address = CRM_Core_BAO_Address::add($addressParams, FALSE); + $address = CRM_Core_BAO_Address::writeRecord($addressParams); return $address->id; } return NULL; diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 004922b0d3..909b4e607f 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -20,96 +20,70 @@ use Civi\Api4\Address; /** * This is class to handle address related functions. */ -class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { +class CRM_Core_BAO_Address extends CRM_Core_DAO_Address implements Civi\Core\HookInterface { use CRM_Contact_AccessTrait; /** - * Takes an associative array and creates a address. + * @deprecated * * @param array $params - * (reference ) an assoc array of name/value pairs. * @param bool $fixAddress - * True if you need to fix (format) address values. - * before inserting in db - * - * @return array|NULL|self - * array of created address + * @return CRM_Core_BAO_Address + * @throws CRM_Core_Exception */ public static function create(array &$params, $fixAddress = TRUE) { - return self::add($params, $fixAddress); + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); + if ($fixAddress) { + CRM_Core_BAO_Address::fixAddress($params); + } + return self::writeRecord($params); } /** - * Takes an associative array and adds address. + * @deprecated * * @param array $params - * (reference ) an assoc array of name/value pairs. * @param bool $fixAddress - * True if you need to fix (format) address values. - * before inserting in db - * - * @return CRM_Core_BAO_Address|null + * @return CRM_Core_BAO_Address + * @throws CRM_Core_Exception */ public static function add(&$params, $fixAddress = FALSE) { + return self::create($params, $fixAddress); + } - $address = new CRM_Core_DAO_Address(); - $checkPermissions = $params['check_permissions'] ?? TRUE; - - // fixAddress mode to be done - if ($fixAddress) { - CRM_Core_BAO_Address::fixAddress($params); - } - - $hook = empty($params['id']) ? 'create' : 'edit'; - CRM_Utils_Hook::pre($hook, 'Address', CRM_Utils_Array::value('id', $params), $params); - - CRM_Core_BAO_Block::handlePrimary($params, get_class()); - CRM_Core_BAO_Block::handleBilling($params, get_class()); - - // (prevent chaining 1 and 3) CRM-21214 - if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) { - self::fixSharedAddress($params); - } - - $address->copyValues($params); - $address->save(); - - if ($address->id) { - // first get custom field from master address if any - if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) { - $address->copyCustomFields($params['master_id'], $address->id, $hook); + /** + * Event fired before modifying an Address. + * @param \Civi\Core\Event\PreEvent $event + */ + public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) { + if (in_array($event->action, ['create', 'edit'])) { + CRM_Core_BAO_Block::handlePrimary($event->params, __CLASS__); + CRM_Core_BAO_Block::handleBilling($event->params, __CLASS__); + + // (prevent chaining 1 and 3) CRM-21214 + if (isset($event->params['master_id']) && !CRM_Utils_System::isNull($event->params['master_id'])) { + self::fixSharedAddress($event->params); } + } + } - if (isset($params['custom'])) { - $addressCustom = $params['custom']; - } - else { - $customFields = CRM_Core_BAO_CustomField::getFields('Address', FALSE, TRUE, NULL, NULL, - FALSE, FALSE, $checkPermissions ? CRM_Core_Permission::EDIT : FALSE); - - if (!empty($customFields)) { - $addressCustom = CRM_Core_BAO_CustomField::postProcess($params, - $address->id, - 'Address', - FALSE, - $checkPermissions - ); - } - } - if (!empty($addressCustom)) { - CRM_Core_BAO_CustomValueTable::store($addressCustom, 'civicrm_address', $address->id, $hook); + /** + * Event fired after modifying an Address. + * @param \Civi\Core\Event\PostEvent $event + */ + public static function self_hook_civicrm_post(\Civi\Core\Event\PostEvent $event) { + // Copy custom data from master address if not supplied + if ($event->action === 'create' && !isset($event->params['custom'])) { + if (isset($event->params['master_id']) && !CRM_Utils_System::isNull($event->params['master_id'])) { + $event->object->copyCustomFields($event->params['master_id'], $event->id, $event->action); } - + } + if (in_array($event->action, ['create', 'edit'])) { // call the function to sync shared address and create relationships // if address is already shared, share master_id with all children and update relationships accordingly // (prevent chaining 2) CRM-21214 - self::processSharedAddress($address->id, $params, $hook); - - // lets call the post hook only after we've done all the follow on processing - CRM_Utils_Hook::post($hook, 'Address', $address->id, $address); + self::processSharedAddress($event->id, $event->params, $event->action); } - - return $address; } /** @@ -1336,7 +1310,6 @@ SELECT is_primary, return NULL; } CRM_Core_BAO_Block::sortPrimaryFirst($params['address']); - $contactId = NULL; $updateBlankLocInfo = CRM_Utils_Array::value('updateBlankLocInfo', $params, FALSE); $contactId = $params['contact_id']; @@ -1386,7 +1359,17 @@ SELECT is_primary, $value['manual_geo_code'] = 0; } $value['contact_id'] = $contactId; - $blocks[] = self::add($value, $fixAddress); + + if ($fixAddress) { + self::fixAddress($value); + } + + // Format custom data + if (!isset($value['custom'])) { + $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, $value['id'] ?? NULL, 'Address'); + } + + $blocks[] = self::writeRecord($value); } return $blocks; } diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index 506e951576..a5abbe73c8 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -282,7 +282,10 @@ class CRM_Core_BAO_Block { } $blockFields = array_merge($value, $contactFields); - $blocks[] = $baoString::create($blockFields); + if ($baoString === 'CRM_Core_BAO_Address') { + CRM_Core_BAO_Address::fixAddress($blockFields); + } + $blocks[] = $baoString::writeRecord($blockFields); } return $blocks; diff --git a/CRM/Event/Form/ManageEvent/Location.php b/CRM/Event/Form/ManageEvent/Location.php index 5d7be182ea..cc41a4447f 100644 --- a/CRM/Event/Form/ManageEvent/Location.php +++ b/CRM/Event/Form/ManageEvent/Location.php @@ -13,7 +13,6 @@ use Civi\Api4\Event; use Civi\Api4\LocBlock; use Civi\Api4\Email; use Civi\Api4\Phone; -use Civi\Api4\Address; /** * @@ -331,8 +330,15 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { } - // Update the Blocks. - $addresses = empty($params['address']) ? [] : Address::save(FALSE)->setRecords($params['address'])->execute(); + // Update location Blocks. + $addresses = []; + // Don't use APIv4 for address because it doesn't handle custom fields in the format used by this form (custom_xx) + foreach ($params['address'] ?? [] as $address) { + CRM_Core_BAO_Address::fixAddress($address); + $address['custom'] = CRM_Core_BAO_CustomField::postProcess($address, $address['id'] ?? NULL, 'Address'); + $addresses[] = (array) CRM_Core_BAO_Address::writeRecord($address); + } + // Using APIv4 for email & phone, the form doesn't support custom data for them anyway $emails = empty($params['email']) ? [] : Email::save(FALSE)->setRecords($params['email'])->execute(); $phones = empty($params['phone']) ? [] : Phone::save(FALSE)->setRecords($params['phone'])->execute(); diff --git a/Civi/Api4/Action/Address/AddressSaveTrait.php b/Civi/Api4/Action/Address/AddressSaveTrait.php index d14fca6a1d..3759e978ed 100644 --- a/Civi/Api4/Action/Address/AddressSaveTrait.php +++ b/Civi/Api4/Action/Address/AddressSaveTrait.php @@ -55,7 +55,10 @@ trait AddressSaveTrait { $item = array_merge($item, \CRM_Core_BAO_Address::parseStreetAddress($item['street_address'])); } $item['skip_geocode'] = $this->skipGeocode; - $saved[] = \CRM_Core_BAO_Address::add($item, $this->fixAddress); + if ($this->fixAddress) { + \CRM_Core_BAO_Address::fixAddress($item); + } + $saved[] = \CRM_Core_BAO_Address::writeRecord($item); } return $saved; } diff --git a/Civi/Test/Api3TestTrait.php b/Civi/Test/Api3TestTrait.php index 49d81e97b4..e00452ab97 100644 --- a/Civi/Test/Api3TestTrait.php +++ b/Civi/Test/Api3TestTrait.php @@ -428,6 +428,11 @@ trait Api3TestTrait { if ($v4Entity != 'Setting' && !in_array('id', $v4Params['select'])) { $v4Params['select'][] = 'id'; } + // Convert 'custom' to 'custom.*' + $selectCustom = array_search('custom', $v4Params['select']); + if ($selectCustom !== FALSE) { + $v4Params['select'][$selectCustom] = 'custom.*'; + } } if ($options['limit'] && $v4Entity != 'Setting') { $v4Params['limit'] = $options['limit']; diff --git a/api/v3/Address.php b/api/v3/Address.php index f7988a249a..dd74c46c11 100644 --- a/api/v3/Address.php +++ b/api/v3/Address.php @@ -60,22 +60,11 @@ function civicrm_api3_address_create($params) { $params['check_permissions'] = 0; } - if (!isset($params['fix_address'])) { - $params['fix_address'] = TRUE; + if (!isset($params['fix_address']) || $params['fix_address']) { + CRM_Core_BAO_Address::fixAddress($params); } - /** - * Create array for BAO (expects address params in as an - * element in array 'address' - */ - $addressBAO = CRM_Core_BAO_Address::create($params, $params['fix_address']); - if (empty($addressBAO)) { - return civicrm_api3_create_error("Address is not created or updated "); - } - else { - $values = _civicrm_api3_dao_to_array($addressBAO, $params); - return civicrm_api3_create_success($values, $params, 'Address', $addressBAO); - } + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Address'); } /** diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index 180f4f37a4..e553e53844 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -1565,7 +1565,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { 'is_billing' => 1, 'state_province_id' => '3934', ]; - $addAddressA = CRM_Core_BAO_Address::add($addressParamsA, FALSE); + $addAddressA = CRM_Core_BAO_Address::writeRecord($addressParamsA); $addressParamsB[1] = [ 'contact_id' => $contactIdB, @@ -1574,7 +1574,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { ]; CRM_Contact_BAO_Contact_Utils::processSharedAddress($addressParamsB); - $addAddressB = CRM_Core_BAO_Address::add($addressParamsB[1], FALSE); + $addAddressB = CRM_Core_BAO_Address::writeRecord($addressParamsB[1]); foreach ($addAddressA as $key => $value) { if (!in_array($key, ['id', 'contact_id', 'master_id', 'is_primary', 'is_billing', 'location_type_id', 'manual_geo_code'])) { diff --git a/tests/phpunit/CRM/Core/BAO/AddressTest.php b/tests/phpunit/CRM/Core/BAO/AddressTest.php index e1c573bf8f..5780a6c0a9 100644 --- a/tests/phpunit/CRM/Core/BAO/AddressTest.php +++ b/tests/phpunit/CRM/Core/BAO/AddressTest.php @@ -112,7 +112,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactId, ]; - $addAddress = CRM_Core_BAO_Address::add($fixParams, $fixAddress = TRUE); + CRM_Core_BAO_Address::fixAddress($fixParams); + $addAddress = CRM_Core_BAO_Address::writeRecord($fixParams); $addParams = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created contact address.' @@ -216,7 +217,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactId, ]; - CRM_Core_BAO_Address::add($params['address']['1'], $fixAddress = TRUE); + CRM_Core_BAO_Address::fixAddress($params['address']['1']); + CRM_Core_BAO_Address::writeRecord($params['address']['1']); // Add address 2 $params['address']['2'] = [ @@ -236,7 +238,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactId, ]; - CRM_Core_BAO_Address::add($params['address']['2'], $fixAddress = TRUE); + CRM_Core_BAO_Address::fixAddress($params['address']['2']); + CRM_Core_BAO_Address::writeRecord($params['address']['2']); $addresses = CRM_Core_BAO_Address::getValues($entityBlock); @@ -281,7 +284,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactId, ]; - CRM_Core_BAO_Address::add($fixParams, $fixAddress = TRUE); + CRM_Core_BAO_Address::fixAddress($fixParams); + CRM_Core_BAO_Address::writeRecord($fixParams); $addParams = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created contact address.' @@ -304,7 +308,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactId, ]; - CRM_Core_BAO_Address::add($fixParams, $fixAddress = TRUE); + CRM_Core_BAO_Address::fixAddress($fixParams); + CRM_Core_BAO_Address::writeRecord($fixParams); $addParams = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created contact address.' @@ -341,7 +346,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactId, ]; - CRM_Core_BAO_Address::add($fixParams, $fixAddress = TRUE); + CRM_Core_BAO_Address::fixAddress($fixParams); + CRM_Core_BAO_Address::writeRecord($fixParams); $addParams = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created contact address.' @@ -585,7 +591,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'is_primary' => '1', 'contact_id' => $contactIdA, ]; - $addAddressA = CRM_Core_BAO_Address::add($addressParamsA, FALSE); + $addAddressA = CRM_Core_BAO_Address::writeRecord($addressParamsA); $addressParamsB = [ 'street_address' => '123 Fake St.', @@ -594,7 +600,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'master_id' => $addAddressA->id, 'contact_id' => $contactIdB, ]; - $addAddressB = CRM_Core_BAO_Address::add($addressParamsB, FALSE); + $addAddressB = CRM_Core_BAO_Address::writeRecord($addressParamsB); $addressParamsC = [ 'street_address' => '123 Fake St.', @@ -603,7 +609,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'master_id' => $addAddressB->id, 'contact_id' => $contactIdC, ]; - $addAddressC = CRM_Core_BAO_Address::add($addressParamsC, FALSE); + $addAddressC = CRM_Core_BAO_Address::writeRecord($addressParamsC); $updatedAddressParamsA = [ 'id' => $addAddressA->id, @@ -612,7 +618,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'is_primary' => '1', 'contact_id' => $contactIdA, ]; - $updatedAddressA = CRM_Core_BAO_Address::add($updatedAddressParamsA, FALSE); + $updatedAddressA = CRM_Core_BAO_Address::writeRecord($updatedAddressParamsA); // CRM-21214 - Has Address C been updated with Address A's new values? $newAddressC = new CRM_Core_DAO_Address(); @@ -645,7 +651,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'is_primary' => '1', 'contact_id' => $contactIdA, ]; - $addAddressA = CRM_Core_BAO_Address::add($addressParamsA, FALSE); + $addAddressA = CRM_Core_BAO_Address::writeRecord($addressParamsA); $addressParamsB = [ 'street_address' => '123 Fake St.', @@ -653,7 +659,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'is_primary' => '1', 'contact_id' => $contactIdB, ]; - $addAddressB = CRM_Core_BAO_Address::add($addressParamsB, FALSE); + $addAddressB = CRM_Core_BAO_Address::writeRecord($addressParamsB); $addressParamsC = [ 'street_address' => '123 Fake St.', @@ -662,7 +668,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'master_id' => $addAddressA->id, 'contact_id' => $contactIdC, ]; - $addAddressC = CRM_Core_BAO_Address::add($addressParamsC, FALSE); + $addAddressC = CRM_Core_BAO_Address::writeRecord($addressParamsC); $updatedAddressParamsA = [ 'id' => $addAddressA->id, @@ -672,7 +678,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'master_id' => $addAddressB->id, 'contact_id' => $contactIdA, ]; - $updatedAddressA = CRM_Core_BAO_Address::add($updatedAddressParamsA, FALSE); + $updatedAddressA = CRM_Core_BAO_Address::writeRecord($updatedAddressParamsA); $updatedAddressParamsB = [ 'id' => $addAddressB->id, @@ -681,7 +687,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'is_primary' => '1', 'contact_id' => $contactIdB, ]; - $updatedAddressB = CRM_Core_BAO_Address::add($updatedAddressParamsB, FALSE); + $updatedAddressB = CRM_Core_BAO_Address::writeRecord($updatedAddressParamsB); // CRM-21214 - Has Address C been updated with Address B's new values? $newAddressC = new CRM_Core_DAO_Address(); @@ -709,7 +715,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'is_primary' => '1', 'contact_id' => $contactIdA, ]; - $addAddressA = CRM_Core_BAO_Address::add($addressParamsA, FALSE); + $addAddressA = CRM_Core_BAO_Address::writeRecord($addressParamsA); $updatedAddressParamsA = [ 'id' => $addAddressA->id, @@ -719,7 +725,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'master_id' => $addAddressA->id, 'contact_id' => $contactIdA, ]; - $updatedAddressA = CRM_Core_BAO_Address::add($updatedAddressParamsA, FALSE); + $updatedAddressA = CRM_Core_BAO_Address::writeRecord($updatedAddressParamsA); // CRM-21214 - AdressA shouldn't be master of itself. $this->assertEmpty($updatedAddressA->master_id); @@ -746,8 +752,9 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactIdA, $customField => 'this is a custom text field', ]; + $addressParamsA['custom'] = CRM_Core_BAO_CustomField::postProcess($addressParamsA, NULL, 'Address'); - $addAddressA = CRM_Core_BAO_Address::add($addressParamsA, FALSE); + $addAddressA = CRM_Core_BAO_Address::writeRecord($addressParamsA); // without having the custom field, we should still copy the values from master $addressParamsB = [ @@ -757,7 +764,7 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'master_id' => $addAddressA->id, 'contact_id' => $contactIdB, ]; - $addAddressB = CRM_Core_BAO_Address::add($addressParamsB, FALSE); + $addAddressB = CRM_Core_BAO_Address::writeRecord($addressParamsB); // 1. check if the custom fields values have been copied from master to shared address $address = $this->callAPISuccessGetSingle('Address', ['id' => $addAddressB->id, 'return' => $this->getCustomFieldName('text')]); @@ -766,7 +773,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { // 2. now, we update addressA custom field to see if it goes into addressB $addressParamsA['id'] = $addAddressA->id; $addressParamsA[$customField] = 'updated custom text field'; - $addAddressA = CRM_Core_BAO_Address::add($addressParamsA, FALSE); + $addressParamsA['custom'] = CRM_Core_BAO_CustomField::postProcess($addressParamsA, NULL, 'Address'); + CRM_Core_BAO_Address::writeRecord($addressParamsA); $address = $this->callAPISuccessGetSingle('Address', ['id' => $addAddressB->id, 'return' => $this->getCustomFieldName('text')]); $this->assertEquals($addressParamsA[$customField], $address[$customField]); @@ -846,7 +854,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { 'contact_id' => $contactId, ]; - $addAddress = CRM_Core_BAO_Address::add($fixParams, TRUE); + CRM_Core_BAO_Address::fixAddress($fixParams); + $addAddress = CRM_Core_BAO_Address::writeRecord($fixParams); $addParams = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created contact address.' diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index 6ea58248e5..271628ae41 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -375,9 +375,11 @@ class api_v3_AddressTest extends CiviUnitTestCase { } /** - * FIXME: Api4 custom address fields broken? + * @param int $version + * @dataProvider versionThreeAndFour */ - public function testGetWithCustom() { + public function testGetWithCustom($version) { + $this->_apiversion = $version; $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); $params = $this->_params; diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 446c5822e1..5e407b2993 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -1184,7 +1184,7 @@ class api_v3_PaymentTest extends CiviUnitTestCase { 'is_primary' => 1, ]; // api requires contact_id - perhaps incorrectly but use add to get past that. - $address = CRM_Core_BAO_Address::add($addressParams); + $address = CRM_Core_BAO_Address::writeRecord($addressParams); $location = $this->callAPISuccess('LocBlock', 'create', ['address_id' => $address->id]); $this->callAPISuccess('Event', 'create', [