From 7cf5bd55da277914f0704a7cae1276899fc36237 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 11 Nov 2019 11:57:37 +1300 Subject: [PATCH] [NFC] reformat CiviUnitTestCase.php --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 791 ++++++++++---------- 1 file changed, 416 insertions(+), 375 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index fae2b981b9..610be7dab8 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -50,6 +50,7 @@ define('API_LATEST_VERSION', 3); * for tests which specifically examine DB transactions. * * Common functions for unit tests + * * @package CiviCRM */ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { @@ -83,6 +84,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { /** * Track tables we have modified during a test. + * * @var array */ protected $_tablesToTruncate = []; @@ -143,7 +145,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { /** * @var array common values to be re-used multiple times within a class - usually to create the relevant entity */ - protected $_params = array(); + protected $_params = []; /** * @var CRM_Extension_System @@ -157,7 +159,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @var array */ - public $setupIDs = array(); + public $setupIDs = []; /** * PHPUnit Mock Method to use. @@ -180,7 +182,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @param array $data * @param string $dataName */ - public function __construct($name = NULL, array $data = array(), $dataName = '') { + public function __construct($name = NULL, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); // we need full error reporting @@ -205,6 +207,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { /** * Override to run the test and assert its state. + * * @return mixed * @throws \Exception * @throws \PHPUnit_Framework_IncompleteTest @@ -269,6 +272,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { /** * @param bool $perClass * @param null $object + * * @return bool * TRUE if the populate logic runs; FALSE if it is skipped */ @@ -298,7 +302,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { static::_populateDB(TRUE); // also set this global hack - $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array(); + $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = []; } /** @@ -338,7 +342,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { CRM_Utils_System::flushCache(); // initialize the object once db is loaded - \Civi::$statics = array(); + \Civi::$statics = []; // ugh, performance $config = CRM_Core_Config::singleton(TRUE, TRUE); @@ -444,7 +448,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ public function createDomainContacts() { $this->organizationCreate(); - $this->organizationCreate(array('organization_name' => 'Second Domain')); + $this->organizationCreate(['organization_name' => 'Second Domain']); } /** @@ -472,7 +476,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { CRM_Core_Transaction::forceRollbackIfEnabled(); \Civi\Core\Transaction\Manager::singleton(TRUE); - $tablesToTruncate = array('civicrm_contact', 'civicrm_uf_match'); + $tablesToTruncate = ['civicrm_contact', 'civicrm_uf_match']; $this->quickCleanup($tablesToTruncate); $this->createDomainContacts(); } @@ -501,10 +505,10 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ public function createExternalAPI() { global $civicrm_root; - $defaultParams = array( + $defaultParams = [ 'version' => $this->_apiversion, 'debug' => 1, - ); + ]; $calls = new \Civi\API\ExternalBatch($defaultParams); @@ -545,11 +549,11 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @return mixed */ - public function membershipTypeCreate($params = array()) { + public function membershipTypeCreate($params = []) { CRM_Member_PseudoConstant::flush('membershipType'); CRM_Core_Config::clearDBCache(); $this->setupIDs['contact'] = $memberOfOrganization = $this->organizationCreate(); - $params = array_merge(array( + $params = array_merge([ 'name' => 'General', 'duration_unit' => 'year', 'duration_interval' => 1, @@ -560,7 +564,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'is_active' => 1, 'sequential' => 1, 'visibility' => 'Public', - ), $params); + ], $params); $result = $this->callAPISuccess('MembershipType', 'Create', $params); @@ -576,17 +580,17 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @return mixed */ public function contactMembershipCreate($params) { - $params = array_merge(array( + $params = array_merge([ 'join_date' => '2007-01-21', 'start_date' => '2007-01-21', 'end_date' => '2007-12-21', 'source' => 'Payment', 'membership_type_id' => 'General', - ), $params); + ], $params); if (!is_numeric($params['membership_type_id'])) { - $membershipTypes = $this->callAPISuccess('Membership', 'getoptions', array('action' => 'create', 'field' => 'membership_type_id')); + $membershipTypes = $this->callAPISuccess('Membership', 'getoptions', ['action' => 'create', 'field' => 'membership_type_id']); if (!in_array($params['membership_type_id'], $membershipTypes['values'])) { - $this->membershipTypeCreate(array('name' => $params['membership_type_id'])); + $this->membershipTypeCreate(['name' => $params['membership_type_id']]); } } @@ -607,7 +611,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @param int $membershipID */ public function membershipDelete($membershipID) { - $deleteParams = array('id' => $membershipID); + $deleteParams = ['id' => $membershipID]; $result = $this->callAPISuccess('Membership', 'Delete', $deleteParams); } @@ -635,7 +639,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { if (!$membershipStatusID) { return; } - $result = $this->callAPISuccess('MembershipStatus', 'Delete', array('id' => $membershipStatusID)); + $result = $this->callAPISuccess('MembershipStatus', 'Delete', ['id' => $membershipStatusID]); } public function membershipRenewalDate($durationUnit, $membershipEndDate) { @@ -662,15 +666,15 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @return mixed */ - public function relationshipTypeCreate($params = array()) { - $params = array_merge(array( + public function relationshipTypeCreate($params = []) { + $params = array_merge([ 'name_a_b' => 'Relation 1 for relationship type create', 'name_b_a' => 'Relation 2 for relationship type create', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Organization', 'is_reserved' => 1, 'is_active' => 1, - ), $params); + ], $params); $result = $this->callAPISuccess('relationship_type', 'create', $params); CRM_Core_PseudoConstant::flush('relationshipType'); @@ -698,7 +702,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ public function paymentProcessorTypeCreate($params = NULL) { if (is_null($params)) { - $params = array( + $params = [ 'name' => 'API_Test_PP', 'title' => 'API Test Payment Processor', 'class_name' => 'CRM_Core_Payment_APITest', @@ -706,7 +710,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'is_recur' => 0, 'is_reserved' => 1, 'is_active' => 1, - ); + ]; } $result = $this->callAPISuccess('payment_processor_type', 'create', $params); @@ -722,8 +726,8 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @return mixed */ - public function paymentProcessorAuthorizeNetCreate($params = array()) { - $params = array_merge(array( + public function paymentProcessorAuthorizeNetCreate($params = []) { + $params = array_merge([ 'name' => 'Authorize', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type_id' => 'AuthNet', @@ -738,7 +742,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'url_recur' => 'https://apitest.authorize.net/xml/v1/request.api', 'class_name' => 'Payment_AuthorizeNet', 'billing_mode' => 1, - ), $params); + ], $params); $result = $this->callAPISuccess('PaymentProcessor', 'create', $params); return $result['id']; @@ -761,14 +765,14 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { $event = $this->eventCreate(); $params['event_id'] = $event['id']; } - $defaults = array( + $defaults = [ 'status_id' => 2, 'role_id' => 1, 'register_date' => 20070219, 'source' => 'Wimbeldon', 'event_level' => 'Payment', 'debug' => 1, - ); + ]; $params = array_merge($defaults, $params); $result = $this->callAPISuccess('Participant', 'create', $params); @@ -781,8 +785,8 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @return int * Id Payment Processor */ - public function processorCreate($params = array()) { - $processorParams = array( + public function processorCreate($params = []) { + $processorParams = [ 'domain_id' => 1, 'name' => 'Dummy', 'payment_processor_type_id' => 'Dummy', @@ -795,7 +799,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'billing_mode' => 1, 'sequential' => 1, 'payment_instrument_id' => 'Debit Card', - ); + ]; $processorParams = array_merge($processorParams, $params); $processor = $this->callAPISuccess('PaymentProcessor', 'create', $processorParams); return $processor['id']; @@ -824,11 +828,12 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Create contribution page. * * @param array $params + * * @return array * Array of contribution page */ - public function contributionPageCreate($params = array()) { - $this->_pageParams = array_merge(array( + public function contributionPageCreate($params = []) { + $this->_pageParams = array_merge([ 'title' => 'Test Contribution Page', 'financial_type_id' => 1, 'currency' => 'USD', @@ -837,7 +842,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'is_allow_other_amount' => 1, 'min_amount' => 10, 'max_amount' => 1000, - ), $params); + ], $params); return $this->callAPISuccess('contribution_page', 'create', $this->_pageParams); } @@ -856,15 +861,16 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Create Tag. * * @param array $params + * * @return array * result of created tag */ - public function tagCreate($params = array()) { - $defaults = array( + public function tagCreate($params = []) { + $defaults = [ 'name' => 'New Tag3', 'description' => 'This is description for Our New Tag ', 'domain_id' => '1', - ); + ]; $params = array_merge($defaults, $params); $result = $this->callAPISuccess('Tag', 'create', $params); return $result['values'][$result['id']]; @@ -880,9 +886,9 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ public function tagDelete($tagId) { require_once 'api/api.php'; - $params = array( + $params = [ 'tag_id' => $tagId, - ); + ]; $result = $this->callAPISuccess('Tag', 'delete', $params); return $result['id']; } @@ -909,7 +915,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * id of created pledge */ public function pledgeCreate($params) { - $params = array_merge(array( + $params = array_merge([ 'pledge_create_date' => date('Ymd'), 'start_date' => date('Ymd'), 'scheduled_date' => date('Ymd'), @@ -921,8 +927,8 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'frequency_unit' => 'year', 'frequency_day' => 15, 'installments' => 5, - ), - $params); + ], + $params); $result = $this->callAPISuccess('Pledge', 'create', $params); return $result['id']; @@ -934,9 +940,9 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @param int $pledgeId */ public function pledgeDelete($pledgeId) { - $params = array( + $params = [ 'pledge_id' => $pledgeId, - ); + ]; $this->callAPISuccess('Pledge', 'delete', $params); } @@ -951,7 +957,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ public function contributionCreate($params) { - $params = array_merge(array( + $params = array_merge([ 'domain_id' => 1, 'receive_date' => date('Ymd'), 'total_amount' => 100.00, @@ -961,7 +967,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'non_deductible_amount' => 10.00, 'source' => 'SSF', 'contribution_status_id' => 1, - ), $params); + ], $params); $result = $this->callAPISuccess('contribution', 'create', $params); return $result['id']; @@ -975,9 +981,9 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @return array|int */ public function contributionDelete($contributionId) { - $params = array( + $params = [ 'contribution_id' => $contributionId, - ); + ]; $result = $this->callAPISuccess('contribution', 'delete', $params); return $result; } @@ -990,18 +996,18 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @return array */ - public function eventCreate($params = array()) { + public function eventCreate($params = []) { // if no contact was passed, make up a dummy event creator if (!isset($params['contact_id'])) { - $params['contact_id'] = $this->_contactCreate(array( + $params['contact_id'] = $this->_contactCreate([ 'contact_type' => 'Individual', 'first_name' => 'Event', 'last_name' => 'Creator', - )); + ]); } // set defaults for missing params - $params = array_merge(array( + $params = array_merge([ 'title' => 'Annual CiviCRM meet', 'summary' => 'If you have any CiviCRM related issues or want to track where CiviCRM is heading, Sign up now', 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues', @@ -1018,7 +1024,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'is_active' => 1, 'is_show_location' => 0, 'is_email_confirm' => 1, - ), $params); + ], $params); return $this->callAPISuccess('Event', 'create', $params); } @@ -1049,9 +1055,9 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @return array|int */ public function eventDelete($id) { - $params = array( + $params = [ 'event_id' => $id, - ); + ]; return $this->callAPISuccess('event', 'delete', $params); } @@ -1063,9 +1069,9 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @return array|int */ public function participantDelete($participantID) { - $params = array( + $params = [ 'id' => $participantID, - ); + ]; $check = $this->callAPISuccess('Participant', 'get', $params); if ($check['count'] > 0) { return $this->callAPISuccess('Participant', 'delete', $params); @@ -1077,15 +1083,16 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @param int $participantID * @param int $contributionID + * * @return int * $id of created payment */ public function participantPaymentCreate($participantID, $contributionID = NULL) { //Create Participant Payment record With Values - $params = array( + $params = [ 'participant_id' => $participantID, 'contribution_id' => $contributionID, - ); + ]; $result = $this->callAPISuccess('participant_payment', 'create', $params); return $result['id']; @@ -1097,9 +1104,9 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @param int $paymentID */ public function participantPaymentDelete($paymentID) { - $params = array( + $params = [ 'id' => $paymentID, - ); + ]; $result = $this->callAPISuccess('participant_payment', 'delete', $params); } @@ -1107,12 +1114,13 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Add a Location. * * @param int $contactID + * * @return int * location id of created location */ public function locationAdd($contactID) { - $address = array( - 1 => array( + $address = [ + 1 => [ 'location_type' => 'New Location Type', 'is_primary' => 1, 'name' => 'Saint Helier St', @@ -1122,15 +1130,15 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', 'supplemental_address_3' => 'My Town', - ), - ); + ], + ]; - $params = array( + $params = [ 'contact_id' => $contactID, 'address' => $address, 'location_format' => '2.0', 'location_type' => 'New Location Type', - ); + ]; $result = $this->callAPISuccess('Location', 'create', $params); return $result; @@ -1150,17 +1158,18 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Add a Location Type. * * @param array $params + * * @return CRM_Core_DAO_LocationType * location id of created location */ public function locationTypeCreate($params = NULL) { if ($params === NULL) { - $params = array( + $params = [ 'name' => 'New Location Type', 'vcard_name' => 'New Location Type', 'description' => 'Location Type for Delete', 'is_active' => 1, - ); + ]; } $locationType = new CRM_Core_DAO_LocationType(); @@ -1168,7 +1177,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { $locationType->save(); // clear getfields cache CRM_Core_PseudoConstant::flush(); - $this->callAPISuccess('phone', 'getfields', array('version' => 3, 'cache_clear' => 1)); + $this->callAPISuccess('phone', 'getfields', ['version' => 3, 'cache_clear' => 1]); return $locationType; } @@ -1187,17 +1196,18 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Add a Mapping. * * @param array $params + * * @return CRM_Core_DAO_Mapping * Mapping id of created mapping */ public function mappingCreate($params = NULL) { if ($params === NULL) { - $params = array( + $params = [ 'name' => 'Mapping name', 'description' => 'Mapping description', // 'Export Contact' mapping. 'mapping_type_id' => 7, - ); + ]; } $mapping = new CRM_Core_DAO_Mapping(); @@ -1205,7 +1215,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { $mapping->save(); // clear getfields cache CRM_Core_PseudoConstant::flush(); - $this->callAPISuccess('mapping', 'getfields', array('version' => 3, 'cache_clear' => 1)); + $this->callAPISuccess('mapping', 'getfields', ['version' => 3, 'cache_clear' => 1]); return $mapping; } @@ -1225,7 +1235,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ protected function prepareForACLs() { $config = CRM_Core_Config::singleton(); - $config->userPermissionClass->permissions = array(); + $config->userPermissionClass->permissions = []; } /** @@ -1233,12 +1243,12 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ protected function cleanUpAfterACLs() { CRM_Utils_Hook::singleton()->reset(); - $tablesToTruncate = array( + $tablesToTruncate = [ 'civicrm_acl', 'civicrm_acl_cache', 'civicrm_acl_entity_role', 'civicrm_acl_contact_cache', - ); + ]; $this->quickCleanup($tablesToTruncate); $config = CRM_Core_Config::singleton(); unset($config->userPermissionClass->permissions); @@ -1268,10 +1278,11 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { /** * Create a UFField. + * * @param array $params */ - public function uFFieldCreate($params = array()) { - $params = array_merge(array( + public function uFFieldCreate($params = []) { + $params = array_merge([ 'uf_group_id' => 1, 'field_name' => 'first_name', 'is_active' => 1, @@ -1281,7 +1292,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'label' => 'first_name', 'field_type' => 'Individual', 'weight' => 1, - ), $params); + ], $params); $this->callAPISuccess('uf_field', 'create', $params); } @@ -1289,19 +1300,20 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Add a UF Join Entry. * * @param array $params + * * @return int * $id of created UF Join */ public function ufjoinCreate($params = NULL) { if ($params === NULL) { - $params = array( + $params = [ 'is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => 3, 'weight' => 1, 'uf_group_id' => 1, - ); + ]; } $result = $this->callAPISuccess('uf_join', 'create', $params); return $result; @@ -1317,12 +1329,12 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @return int * Campaign ID. */ - public function campaignCreate($params = array(), $reloadConfig = TRUE) { + public function campaignCreate($params = [], $reloadConfig = TRUE) { $this->enableCiviCampaign($reloadConfig); - $campaign = $this->callAPISuccess('campaign', 'create', array_merge(array( + $campaign = $this->callAPISuccess('campaign', 'create', array_merge([ 'name' => 'big_campaign', 'title' => 'Campaign', - ), $params)); + ], $params)); return $campaign['id']; } @@ -1332,10 +1344,10 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @param int $contactId */ public function contactGroupCreate($contactId) { - $params = array( + $params = [ 'contact_id.1' => $contactId, 'group_id' => 1, - ); + ]; $this->callAPISuccess('GroupContact', 'Create', $params); } @@ -1346,10 +1358,10 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @param int $contactId */ public function contactGroupDelete($contactId) { - $params = array( + $params = [ 'contact_id.1' => $contactId, 'group_id' => 1, - ); + ]; $this->civicrm_api('GroupContact', 'Delete', $params); } @@ -1357,10 +1369,11 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Create Activity. * * @param array $params + * * @return array|int */ - public function activityCreate($params = array()) { - $params = array_merge(array( + public function activityCreate($params = []) { + $params = array_merge([ 'subject' => 'Discussion on warm beer', 'activity_date_time' => date('Ymd'), 'duration_hours' => 30, @@ -1369,18 +1382,18 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'details' => 'Lets schedule a meeting', 'status_id' => 1, 'activity_type_id' => 'Meeting', - ), $params); + ], $params); if (!isset($params['source_contact_id'])) { $params['source_contact_id'] = $this->individualCreate(); } if (!isset($params['target_contact_id'])) { - $params['target_contact_id'] = $this->individualCreate(array( + $params['target_contact_id'] = $this->individualCreate([ 'first_name' => 'Julia', 'last_name' => 'Anderson', 'prefix' => 'Ms.', 'email' => 'julia_anderson@civicrm.org', 'contact_type' => 'Individual', - )); + ]); } if (!isset($params['assignee_contact_id'])) { $params['assignee_contact_id'] = $params['target_contact_id']; @@ -1398,6 +1411,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @param array $params * Parameters. + * * @return array */ public function activityTypeCreate($params) { @@ -1409,6 +1423,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @param int $activityTypeId * Id of the activity type. + * * @return array */ public function activityTypeDelete($activityTypeId) { @@ -1420,16 +1435,17 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Create custom group. * * @param array $params + * * @return array */ - public function customGroupCreate($params = array()) { - $defaults = array( + public function customGroupCreate($params = []) { + $defaults = [ 'title' => 'new custom group', 'extends' => 'Contact', 'domain_id' => 1, 'style' => 'Inline', 'is_active' => 1, - ); + ]; $params = array_merge($defaults, $params); @@ -1439,68 +1455,74 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { /** * Existing function doesn't allow params to be over-ridden so need a new one * this one allows you to only pass in the params you want to change + * * @param array $params + * * @return array|int */ - public function CustomGroupCreateByParams($params = array()) { - $defaults = array( + public function CustomGroupCreateByParams($params = []) { + $defaults = [ 'title' => "API Custom Group", 'extends' => 'Contact', 'domain_id' => 1, 'style' => 'Inline', 'is_active' => 1, - ); + ]; $params = array_merge($defaults, $params); return $this->callAPISuccess('custom_group', 'create', $params); } /** * Create custom group with multi fields. + * * @param array $params + * * @return array|int */ - public function CustomGroupMultipleCreateByParams($params = array()) { - $defaults = array( + public function CustomGroupMultipleCreateByParams($params = []) { + $defaults = [ 'style' => 'Tab', 'is_multiple' => 1, - ); + ]; $params = array_merge($defaults, $params); return $this->CustomGroupCreateByParams($params); } /** * Create custom group with multi fields. + * * @param array $params + * * @return array */ - public function CustomGroupMultipleCreateWithFields($params = array()) { + public function CustomGroupMultipleCreateWithFields($params = []) { // also need to pass on $params['custom_field'] if not set but not in place yet - $ids = array(); + $ids = []; $customGroup = $this->CustomGroupMultipleCreateByParams($params); $ids['custom_group_id'] = $customGroup['id']; - $customField = $this->customFieldCreate(array( + $customField = $this->customFieldCreate([ 'custom_group_id' => $ids['custom_group_id'], 'label' => 'field_1' . $ids['custom_group_id'], 'in_selector' => 1, - )); + ]); $ids['custom_field_id'][] = $customField['id']; - $customField = $this->customFieldCreate(array( + $customField = $this->customFieldCreate([ 'custom_group_id' => $ids['custom_group_id'], 'default_value' => '', 'label' => 'field_2' . $ids['custom_group_id'], 'in_selector' => 1, - )); + ]); $ids['custom_field_id'][] = $customField['id']; - $customField = $this->customFieldCreate(array( + $customField = $this->customFieldCreate([ 'custom_group_id' => $ids['custom_group_id'], 'default_value' => '', 'label' => 'field_3' . $ids['custom_group_id'], 'in_selector' => 1, - )); + ]); $ids['custom_field_id'][] = $customField['id']; return $ids; @@ -1519,14 +1541,14 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * ids of created objects */ public function entityCustomGroupWithSingleFieldCreate($function, $filename) { - $params = array('title' => $function); + $params = ['title' => $function]; $entity = substr(basename($filename), 0, strlen(basename($filename)) - 8); $params['extends'] = $entity ? $entity : 'Contact'; $customGroup = $this->customGroupCreate($params); - $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id'], 'label' => $function)); + $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id'], 'label' => $function]); CRM_Core_PseudoConstant::flush(); - return array('custom_group_id' => $customGroup['id'], 'custom_field_id' => $customField['id']); + return ['custom_group_id' => $customGroup['id'], 'custom_field_id' => $customField['id']]; } /** @@ -1542,11 +1564,11 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * ids of created objects */ public function entityCustomGroupWithSingleStringMultiSelectFieldCreate($function, $filename) { - $params = array('title' => $function); + $params = ['title' => $function]; $entity = substr(basename($filename), 0, strlen(basename($filename)) - 8); $params['extends'] = $entity ? $entity : 'Contact'; $customGroup = $this->customGroupCreate($params); - $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id'], 'label' => $function, 'html_type' => 'Multi-Select', 'default_value' => 1)); + $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id'], 'label' => $function, 'html_type' => 'Multi-Select', 'default_value' => 1]); CRM_Core_PseudoConstant::flush(); $options = [ 'defaultValue' => 'Default Value', @@ -1565,7 +1587,12 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { $option_value_result = $this->callAPISuccess('OptionValue', 'create', $option_group_params); } - return array('custom_group_id' => $customGroup['id'], 'custom_field_id' => $customField['id'], 'custom_field_option_group_id' => $custom_field_api_result['values'][0]['option_group_id'], 'custom_field_group_options' => $options); + return [ + 'custom_group_id' => $customGroup['id'], + 'custom_field_id' => $customField['id'], + 'custom_field_option_group_id' => $custom_field_api_result['values'][0]['option_group_id'], + 'custom_field_group_options' => $options, + ]; } /** @@ -1585,17 +1612,18 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @param array $params * (custom_group_id) is required. + * * @return array */ public function customFieldCreate($params) { - $params = array_merge(array( + $params = array_merge([ 'label' => 'Custom Field', 'data_type' => 'String', 'html_type' => 'Text', 'is_searchable' => 1, 'is_active' => 1, 'default_value' => 'defaultValue', - ), $params); + ], $params); $result = $this->callAPISuccess('custom_field', 'create', $params); // these 2 functions are called with force to flush static caches @@ -1621,17 +1649,18 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Create note. * * @param int $cId + * * @return array */ public function noteCreate($cId) { - $params = array( + $params = [ 'entity_table' => 'civicrm_contact', 'entity_id' => $cId, 'note' => 'hello I am testing Note', 'contact_id' => $cId, 'modified_date' => date('Ymd'), 'subject' => 'Test Note', - ); + ]; return $this->callAPISuccess('Note', 'create', $params); } @@ -1663,8 +1692,8 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @return array|int */ - public function customFieldOptionValueCreate($customGroup, $name, $extraParams = array()) { - $fieldParams = array( + public function customFieldOptionValueCreate($customGroup, $name, $extraParams = []) { + $fieldParams = [ 'custom_group_id' => $customGroup['id'], 'name' => 'test_custom_group', 'label' => 'Country', @@ -1674,21 +1703,21 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'is_required' => 1, 'is_searchable' => 0, 'is_active' => 1, - ); + ]; - $optionGroup = array( + $optionGroup = [ 'domain_id' => 1, 'name' => 'option_group1', 'label' => 'option_group_label1', - ); + ]; - $optionValue = array( - 'option_label' => array('Label1', 'Label2'), - 'option_value' => array('value1', 'value2'), - 'option_name' => array($name . '_1', $name . '_2'), - 'option_weight' => array(1, 2), - 'option_status' => array(1, 1), - ); + $optionValue = [ + 'option_label' => ['Label1', 'Label2'], + 'option_value' => ['value1', 'value2'], + 'option_name' => [$name . '_1', $name . '_2'], + 'option_weight' => [1, 2], + 'option_status' => [1, 1], + ]; $params = array_merge($fieldParams, $optionGroup, $optionValue, $extraParams); @@ -1703,7 +1732,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { public function confirmEntitiesDeleted($entities) { foreach ($entities as $entity) { - $result = $this->callAPISuccess($entity, 'Get', array()); + $result = $this->callAPISuccess($entity, 'Get', []); if ($result['error'] == 1 || $result['count'] > 0) { // > than $entity[0] to allow a value to be passed in? e.g. domain? return TRUE; @@ -1717,6 +1746,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @param array $tablesToTruncate * @param bool $dropCustomValueTables + * * @throws \CRM_Core_Exception */ public function quickCleanup($tablesToTruncate, $dropCustomValueTables = FALSE) { @@ -1764,7 +1794,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * Clean up financial entities after financial tests (so we remember to get all the tables :-)) */ public function quickCleanUpFinancialEntities() { - $tablesToTruncate = array( + $tablesToTruncate = [ 'civicrm_activity', 'civicrm_activity_contact', 'civicrm_contribution', @@ -1791,7 +1821,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'civicrm_price_set_entity', 'civicrm_price_field_value', 'civicrm_price_field', - ); + ]; $this->quickCleanup($tablesToTruncate); CRM_Core_DAO::executeQuery("DELETE FROM civicrm_membership_status WHERE name NOT IN('New', 'Current', 'Grace', 'Expired', 'Pending', 'Cancelled', 'Deceased')"); $this->restoreDefaultPriceSetConfig(); @@ -1839,17 +1869,17 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) */ public function getAndCheck($params, $id, $entity, $delete = 1, $errorText = '') { - $result = $this->callAPISuccessGetSingle($entity, array( + $result = $this->callAPISuccessGetSingle($entity, [ 'id' => $id, - )); + ]); if ($delete) { - $this->callAPISuccess($entity, 'Delete', array( + $this->callAPISuccess($entity, 'Delete', [ 'id' => $id, - )); + ]); } - $dateFields = $keys = $dateTimeFields = array(); - $fields = $this->callAPISuccess($entity, 'getfields', array('version' => 3, 'action' => 'get')); + $dateFields = $keys = $dateTimeFields = []; + $fields = $this->callAPISuccess($entity, 'getfields', ['version' => 3, 'action' => 'get']); foreach ($fields['values'] as $field => $settings) { if (array_key_exists($field, $result)) { $keys[CRM_Utils_Array::value('name', $settings, $field)] = $field; @@ -1900,6 +1930,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) /** * Get formatted values in the actual and expected result. + * * @param array $actual * Actual calculated values. * @param array $expected @@ -1913,11 +1944,12 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) /** * Unset the key 'id' from the array + * * @param array $unformattedArray * The array from which the 'id' has to be unset. */ public static function unsetId(&$unformattedArray) { - $formattedArray = array(); + $formattedArray = []; if (array_key_exists('id', $unformattedArray)) { unset($unformattedArray['id']); } @@ -1933,7 +1965,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) elseif ($key == 'id') { $unformattedArray[$key]; } - $formattedArray = array($value); + $formattedArray = [$value]; } $unformattedArray['values'] = $formattedArray; } @@ -1975,6 +2007,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * Generate a temporary folder. * * @param string $prefix + * * @return string */ public function createTempDir($prefix = 'test-') { @@ -1997,6 +2030,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) /** * Temporarily replace the singleton extension with a different one. + * * @param \CRM_Extension_System $system */ public function setExtensionSystem(CRM_Extension_System $system) { @@ -2019,6 +2053,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * WARNING: The setting metadata will disappear on the next cache-clear. * * @param $extras + * * @return void */ public function setMockSettingsMetaData($extras) { @@ -2029,7 +2064,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) Civi::service('settings_manager')->flush(); - $fields = $this->callAPISuccess('setting', 'getfields', array()); + $fields = $this->callAPISuccess('setting', 'getfields', []); foreach ($extras as $key => $spec) { $this->assertNotEmpty($spec['title']); $this->assertEquals($spec['title'], $fields['values'][$key]['title']); @@ -2055,171 +2090,171 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * (NB unclear if this is still required) */ public function _sethtmlGlobals() { - $GLOBALS['_HTML_QuickForm_registered_rules'] = array( - 'required' => array( + $GLOBALS['_HTML_QuickForm_registered_rules'] = [ + 'required' => [ 'html_quickform_rule_required', 'HTML/QuickForm/Rule/Required.php', - ), - 'maxlength' => array( + ], + 'maxlength' => [ 'html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php', - ), - 'minlength' => array( + ], + 'minlength' => [ 'html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php', - ), - 'rangelength' => array( + ], + 'rangelength' => [ 'html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php', - ), - 'email' => array( + ], + 'email' => [ 'html_quickform_rule_email', 'HTML/QuickForm/Rule/Email.php', - ), - 'regex' => array( + ], + 'regex' => [ 'html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php', - ), - 'lettersonly' => array( + ], + 'lettersonly' => [ 'html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php', - ), - 'alphanumeric' => array( + ], + 'alphanumeric' => [ 'html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php', - ), - 'numeric' => array( + ], + 'numeric' => [ 'html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php', - ), - 'nopunctuation' => array( + ], + 'nopunctuation' => [ 'html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php', - ), - 'nonzero' => array( + ], + 'nonzero' => [ 'html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php', - ), - 'callback' => array( + ], + 'callback' => [ 'html_quickform_rule_callback', 'HTML/QuickForm/Rule/Callback.php', - ), - 'compare' => array( + ], + 'compare' => [ 'html_quickform_rule_compare', 'HTML/QuickForm/Rule/Compare.php', - ), - ); + ], + ]; // FIXME: …ditto for $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] - $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = array( - 'group' => array( + $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = [ + 'group' => [ 'HTML/QuickForm/group.php', 'HTML_QuickForm_group', - ), - 'hidden' => array( + ], + 'hidden' => [ 'HTML/QuickForm/hidden.php', 'HTML_QuickForm_hidden', - ), - 'reset' => array( + ], + 'reset' => [ 'HTML/QuickForm/reset.php', 'HTML_QuickForm_reset', - ), - 'checkbox' => array( + ], + 'checkbox' => [ 'HTML/QuickForm/checkbox.php', 'HTML_QuickForm_checkbox', - ), - 'file' => array( + ], + 'file' => [ 'HTML/QuickForm/file.php', 'HTML_QuickForm_file', - ), - 'image' => array( + ], + 'image' => [ 'HTML/QuickForm/image.php', 'HTML_QuickForm_image', - ), - 'password' => array( + ], + 'password' => [ 'HTML/QuickForm/password.php', 'HTML_QuickForm_password', - ), - 'radio' => array( + ], + 'radio' => [ 'HTML/QuickForm/radio.php', 'HTML_QuickForm_radio', - ), - 'button' => array( + ], + 'button' => [ 'HTML/QuickForm/button.php', 'HTML_QuickForm_button', - ), - 'submit' => array( + ], + 'submit' => [ 'HTML/QuickForm/submit.php', 'HTML_QuickForm_submit', - ), - 'select' => array( + ], + 'select' => [ 'HTML/QuickForm/select.php', 'HTML_QuickForm_select', - ), - 'hiddenselect' => array( + ], + 'hiddenselect' => [ 'HTML/QuickForm/hiddenselect.php', 'HTML_QuickForm_hiddenselect', - ), - 'text' => array( + ], + 'text' => [ 'HTML/QuickForm/text.php', 'HTML_QuickForm_text', - ), - 'textarea' => array( + ], + 'textarea' => [ 'HTML/QuickForm/textarea.php', 'HTML_QuickForm_textarea', - ), - 'fckeditor' => array( + ], + 'fckeditor' => [ 'HTML/QuickForm/fckeditor.php', 'HTML_QuickForm_FCKEditor', - ), - 'tinymce' => array( + ], + 'tinymce' => [ 'HTML/QuickForm/tinymce.php', 'HTML_QuickForm_TinyMCE', - ), - 'dojoeditor' => array( + ], + 'dojoeditor' => [ 'HTML/QuickForm/dojoeditor.php', 'HTML_QuickForm_dojoeditor', - ), - 'link' => array( + ], + 'link' => [ 'HTML/QuickForm/link.php', 'HTML_QuickForm_link', - ), - 'advcheckbox' => array( + ], + 'advcheckbox' => [ 'HTML/QuickForm/advcheckbox.php', 'HTML_QuickForm_advcheckbox', - ), - 'date' => array( + ], + 'date' => [ 'HTML/QuickForm/date.php', 'HTML_QuickForm_date', - ), - 'static' => array( + ], + 'static' => [ 'HTML/QuickForm/static.php', 'HTML_QuickForm_static', - ), - 'header' => array( + ], + 'header' => [ 'HTML/QuickForm/header.php', 'HTML_QuickForm_header', - ), - 'html' => array( + ], + 'html' => [ 'HTML/QuickForm/html.php', 'HTML_QuickForm_html', - ), - 'hierselect' => array( + ], + 'hierselect' => [ 'HTML/QuickForm/hierselect.php', 'HTML_QuickForm_hierselect', - ), - 'autocomplete' => array( + ], + 'autocomplete' => [ 'HTML/QuickForm/autocomplete.php', 'HTML_QuickForm_autocomplete', - ), - 'xbutton' => array( + ], + 'xbutton' => [ 'HTML/QuickForm/xbutton.php', 'HTML_QuickForm_xbutton', - ), - 'advmultiselect' => array( + ], + 'advmultiselect' => [ 'HTML/QuickForm/advmultiselect.php', 'HTML_QuickForm_advmultiselect', - ), - ); + ], + ]; } /** @@ -2237,19 +2272,19 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) global $_REQUEST; $_REQUEST = $this->_params; - CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM'); - $optionGroupID = $this->callAPISuccessGetValue('option_group', array('return' => 'id', 'name' => 'acl_role')); + CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM']; + $optionGroupID = $this->callAPISuccessGetValue('option_group', ['return' => 'id', 'name' => 'acl_role']); $ov = new CRM_Core_DAO_OptionValue(); $ov->option_group_id = $optionGroupID; $ov->value = 55; if ($ov->find(TRUE)) { CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_value WHERE id = {$ov->id}"); } - $optionValue = $this->callAPISuccess('option_value', 'create', array( + $optionValue = $this->callAPISuccess('option_value', 'create', [ 'option_group_id' => $optionGroupID, 'label' => 'pick me', 'value' => 55, - )); + ]); CRM_Core_DAO::executeQuery(" TRUNCATE civicrm_acl_cache @@ -2296,10 +2331,10 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) } $this->_loggedInUser = CRM_Core_Session::singleton()->get('userID'); - $this->callAPISuccess('group_contact', 'create', array( + $this->callAPISuccess('group_contact', 'create', [ 'group_id' => $this->_permissionedGroup, 'contact_id' => $this->_loggedInUser, - )); + ]); if (!$isProfile) { //flush cache @@ -2312,46 +2347,49 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * Alter default price set so that the field numbers are not all 1 (hiding errors) */ public function offsetDefaultPriceSet() { - $contributionPriceSet = $this->callAPISuccess('price_set', 'getsingle', array('name' => 'default_contribution_amount')); + $contributionPriceSet = $this->callAPISuccess('price_set', 'getsingle', ['name' => 'default_contribution_amount']); $firstID = $contributionPriceSet['id']; - $this->callAPISuccess('price_set', 'create', array( + $this->callAPISuccess('price_set', 'create', [ 'id' => $contributionPriceSet['id'], 'is_active' => 0, 'name' => 'old', - )); + ]); unset($contributionPriceSet['id']); $newPriceSet = $this->callAPISuccess('price_set', 'create', $contributionPriceSet); - $priceField = $this->callAPISuccess('price_field', 'getsingle', array( + $priceField = $this->callAPISuccess('price_field', 'getsingle', [ 'price_set_id' => $firstID, - 'options' => array('limit' => 1), - )); + 'options' => ['limit' => 1], + ]); unset($priceField['id']); $priceField['price_set_id'] = $newPriceSet['id']; $newPriceField = $this->callAPISuccess('price_field', 'create', $priceField); - $priceFieldValue = $this->callAPISuccess('price_field_value', 'getsingle', array( + $priceFieldValue = $this->callAPISuccess('price_field_value', 'getsingle', [ 'price_set_id' => $firstID, 'sequential' => 1, - 'options' => array('limit' => 1), - )); + 'options' => ['limit' => 1], + ]); unset($priceFieldValue['id']); //create some padding to use up ids $this->callAPISuccess('price_field_value', 'create', $priceFieldValue); $this->callAPISuccess('price_field_value', 'create', $priceFieldValue); - $this->callAPISuccess('price_field_value', 'create', array_merge($priceFieldValue, array('price_field_id' => $newPriceField['id']))); + $this->callAPISuccess('price_field_value', 'create', array_merge($priceFieldValue, ['price_field_id' => $newPriceField['id']])); } /** * Create an instance of the paypal processor. + * * @todo this isn't a great place to put it - but really it belongs on a class that extends * this parent class & we don't have a structure for that yet * There is another function to this effect on the PaypalPro test but it appears to be silently failing * & the best protection against that is the functions this class affords + * * @param array $params + * * @return int $result['id'] payment processor id */ - public function paymentProcessorCreate($params = array()) { - $params = array_merge(array( + public function paymentProcessorCreate($params = []) { + $params = array_merge([ 'name' => 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type_id' => 'PayPal', @@ -2370,14 +2408,14 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'financial_account_id' => 12, // Credit card = 1 so can pass 'by accident'. 'payment_instrument_id' => 'Debit Card', - ), $params); + ], $params); if (!is_numeric($params['payment_processor_type_id'])) { // really the api should handle this through getoptions but it's not exactly api call so lets just sort it //here - $params['payment_processor_type_id'] = $this->callAPISuccess('payment_processor_type', 'getvalue', array( + $params['payment_processor_type_id'] = $this->callAPISuccess('payment_processor_type', 'getvalue', [ 'name' => $params['payment_processor_type_id'], 'return' => 'id', - ), 'integer'); + ], 'integer'); } $result = $this->callAPISuccess('payment_processor', 'create', $params); return $result['id']; @@ -2402,7 +2440,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'receive_date' => '2019-07-25 07:34:23', 'skipCleanMoney' => TRUE, ], $contributionParams); - $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge(array( + $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge([ 'contact_id' => $this->_contactID, 'amount' => 1000, 'sequential' => 1, @@ -2415,7 +2453,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) // processor provided ID - use contact ID as proxy. 'processor_id' => $this->_contactID, 'api.contribution.create' => $contributionParams, - ), $recurParams)); + ], $recurParams)); $this->_contributionRecurID = $contributionRecur['id']; $this->_contributionID = $contributionRecur['values']['0']['api.contribution.create']['id']; } @@ -2425,8 +2463,8 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * * @param array $params Optionally modify params for membership/recur (duration_unit/frequency_unit) */ - public function setupMembershipRecurringPaymentProcessorTransaction($params = array()) { - $membershipParams = $recurParams = array(); + public function setupMembershipRecurringPaymentProcessorTransaction($params = []) { + $membershipParams = $recurParams = []; if (!empty($params['duration_unit'])) { $membershipParams['duration_unit'] = $params['duration_unit']; } @@ -2436,29 +2474,29 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) $this->ids['membership_type'] = $this->membershipTypeCreate($membershipParams); //create a contribution so our membership & contribution don't both have id = 1 - if ($this->callAPISuccess('Contribution', 'getcount', array()) == 0) { - $this->contributionCreate(array( + if ($this->callAPISuccess('Contribution', 'getcount', []) == 0) { + $this->contributionCreate([ 'contact_id' => $this->_contactID, 'is_test' => 1, 'financial_type_id' => 1, 'invoice_id' => 'abcd', 'trxn_id' => 345, 'receive_date' => '2019-07-25 07:34:23', - )); + ]); } $this->setupRecurringPaymentProcessorTransaction($recurParams); - $this->ids['membership'] = $this->callAPISuccess('membership', 'create', array( + $this->ids['membership'] = $this->callAPISuccess('membership', 'create', [ 'contact_id' => $this->_contactID, 'membership_type_id' => $this->ids['membership_type'], 'contribution_recur_id' => $this->_contributionRecurID, 'format.only_id' => TRUE, 'source' => 'Payment', - )); + ]); //CRM-15055 creates line items we don't want so get rid of them so we can set up our own line items CRM_Core_DAO::executeQuery("TRUNCATE civicrm_line_item"); - $this->callAPISuccess('line_item', 'create', array( + $this->callAPISuccess('line_item', 'create', [ 'entity_table' => 'civicrm_membership', 'entity_id' => $this->ids['membership'], 'contribution_id' => $this->_contributionID, @@ -2467,21 +2505,21 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'unit_price' => 200, 'line_total' => 200, 'financial_type_id' => 1, - 'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', array( + 'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', [ 'return' => 'id', 'label' => 'Membership Amount', - 'options' => array('limit' => 1, 'sort' => 'id DESC'), - )), - 'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', array( + 'options' => ['limit' => 1, 'sort' => 'id DESC'], + ]), + 'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', [ 'return' => 'id', 'label' => 'General', - 'options' => array('limit' => 1, 'sort' => 'id DESC'), - )), - )); - $this->callAPISuccess('membership_payment', 'create', array( + 'options' => ['limit' => 1, 'sort' => 'id DESC'], + ]), + ]); + $this->callAPISuccess('membership_payment', 'create', [ 'contribution_id' => $this->_contributionID, 'membership_id' => $this->ids['membership'], - )); + ]); } /** @@ -2526,12 +2564,12 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) $fileId = $apiResult['id']; $this->assertTrue(is_numeric($fileId)); $this->assertEquals($exists, file_exists($apiResult['values'][$fileId]['path'])); - $this->assertDBQuery($exists ? 1 : 0, 'SELECT count(*) FROM civicrm_file WHERE id = %1', array( - 1 => array($fileId, 'Int'), - )); - $this->assertDBQuery($exists ? 1 : 0, 'SELECT count(*) FROM civicrm_entity_file WHERE id = %1', array( - 1 => array($fileId, 'Int'), - )); + $this->assertDBQuery($exists ? 1 : 0, 'SELECT count(*) FROM civicrm_file WHERE id = %1', [ + 1 => [$fileId, 'Int'], + ]); + $this->assertDBQuery($exists ? 1 : 0, 'SELECT count(*) FROM civicrm_entity_file WHERE id = %1', [ + 1 => [$fileId, 'Int'], + ]); } /** @@ -2569,33 +2607,33 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) $priceSet = CRM_Price_BAO_PriceSet::create($paramsSet); $this->_ids['price_set'] = $priceSet->id; - $paramsField = array( + $paramsField = [ 'label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => $type, 'price' => $feeTotal, - 'option_label' => array('1' => 'Price Field'), - 'option_value' => array('1' => $feeTotal), - 'option_name' => array('1' => $feeTotal), - 'option_weight' => array('1' => 1), - 'option_amount' => array('1' => 1), + 'option_label' => ['1' => 'Price Field'], + 'option_value' => ['1' => $feeTotal], + 'option_name' => ['1' => $feeTotal], + 'option_weight' => ['1' => 1], + 'option_amount' => ['1' => 1], 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, - 'is_active' => array('1' => 1), + 'is_active' => ['1' => 1], 'price_set_id' => $this->_ids['price_set'], 'is_enter_qty' => 1, 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), - ); + ]; if ($type === 'Radio') { $paramsField['is_enter_qty'] = 0; $paramsField['option_value'][2] = $paramsField['option_weight'][2] = $paramsField['option_amount'][2] = 100; $paramsField['option_label'][2] = $paramsField['option_name'][2] = 'hundy'; } $this->callAPISuccess('PriceField', 'create', $paramsField); - $fields = $this->callAPISuccess('PriceField', 'get', array('price_set_id' => $this->_ids['price_set'])); + $fields = $this->callAPISuccess('PriceField', 'get', ['price_set_id' => $this->_ids['price_set']]); $this->_ids['price_field'] = array_keys($fields['values']); - $fieldValues = $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $this->_ids['price_field'][0])); + $fieldValues = $this->callAPISuccess('PriceFieldValue', 'get', ['price_field_id' => $this->_ids['price_field'][0]]); $this->_ids['price_field_value'] = array_keys($fieldValues['values']); return $this->_ids['price_set']; @@ -2644,7 +2682,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * * @return array */ - protected function createPriceSet($component = 'contribution_page', $componentId = NULL, $priceFieldOptions = array()) { + protected function createPriceSet($component = 'contribution_page', $componentId = NULL, $priceFieldOptions = []) { $paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 7); $paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']); $paramsSet['is_active'] = TRUE; @@ -2656,29 +2694,29 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset' ); - $paramsField = array_merge(array( + $paramsField = array_merge([ 'label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'CheckBox', - 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), - 'option_value' => array('1' => 100, '2' => 200), - 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), - 'option_weight' => array('1' => 1, '2' => 2), - 'option_amount' => array('1' => 100, '2' => 200), + 'option_label' => ['1' => 'Price Field 1', '2' => 'Price Field 2'], + 'option_value' => ['1' => 100, '2' => 200], + 'option_name' => ['1' => 'Price Field 1', '2' => 'Price Field 2'], + 'option_weight' => ['1' => 1, '2' => 2], + 'option_amount' => ['1' => 100, '2' => 200], 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, - 'is_active' => array('1' => 1, '2' => 1), + 'is_active' => ['1' => 1, '2' => 1], 'price_set_id' => $priceSet['id'], 'is_enter_qty' => 1, 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), - ), $priceFieldOptions); + ], $priceFieldOptions); $priceField = CRM_Price_BAO_PriceField::create($paramsField); if ($componentId) { CRM_Price_BAO_PriceSet::addTo('civicrm_' . $component, $componentId, $priceSetId); } - return $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $priceField->id)); + return $this->callAPISuccess('PriceFieldValue', 'get', ['price_field_id' => $priceField->id]); } /** @@ -2733,7 +2771,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) CRM_Contribute_PseudoConstant::flush('membershipType'); // Pseudoconstants may be saved to the cache table. CRM_Core_DAO::executeQuery("TRUNCATE civicrm_cache"); - CRM_Financial_BAO_FinancialType::$_statusACLFt = array(); + CRM_Financial_BAO_FinancialType::$_statusACLFt = []; CRM_Financial_BAO_FinancialType::$_availableFinancialTypes = NULL; } @@ -2752,11 +2790,11 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * @param $context */ public function _checkFinancialRecords($params, $context) { - $entityParams = array( + $entityParams = [ 'entity_id' => $params['id'], 'entity_table' => 'civicrm_contribution', - ); - $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $params['id'])); + ]; + $contribution = $this->callAPISuccess('contribution', 'getsingle', ['id' => $params['id']]); $this->assertEquals($contribution['total_amount'] - $contribution['fee_amount'], $contribution['net_amount']); if ($context == 'pending') { $trxn = CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams); @@ -2764,89 +2802,89 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) return; } $trxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams)); - $trxnParams = array( + $trxnParams = [ 'id' => $trxn['financial_trxn_id'], - ); + ]; if ($context != 'online' && $context != 'payLater') { - $compareParams = array( + $compareParams = [ 'to_financial_account_id' => 6, 'total_amount' => CRM_Utils_Array::value('total_amount', $params, 100), 'status_id' => 1, - ); + ]; } if ($context == 'feeAmount') { $compareParams['fee_amount'] = 50; } elseif ($context == 'online') { - $compareParams = array( + $compareParams = [ 'to_financial_account_id' => 12, 'total_amount' => CRM_Utils_Array::value('total_amount', $params, 100), 'status_id' => 1, 'payment_instrument_id' => CRM_Utils_Array::value('payment_instrument_id', $params, 1), - ); + ]; } elseif ($context == 'payLater') { - $compareParams = array( + $compareParams = [ 'to_financial_account_id' => 7, 'total_amount' => CRM_Utils_Array::value('total_amount', $params, 100), 'status_id' => 2, - ); + ]; } $this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams, $compareParams); - $entityParams = array( + $entityParams = [ 'financial_trxn_id' => $trxn['financial_trxn_id'], 'entity_table' => 'civicrm_financial_item', - ); + ]; $entityTrxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($entityParams)); - $fitemParams = array( + $fitemParams = [ 'id' => $entityTrxn['entity_id'], - ); - $compareParams = array( + ]; + $compareParams = [ 'amount' => CRM_Utils_Array::value('total_amount', $params, 100), 'status_id' => 1, 'financial_account_id' => CRM_Utils_Array::value('financial_account_id', $params, 1), - ); + ]; if ($context == 'payLater') { - $compareParams = array( + $compareParams = [ 'amount' => CRM_Utils_Array::value('total_amount', $params, 100), 'status_id' => 3, 'financial_account_id' => CRM_Utils_Array::value('financial_account_id', $params, 1), - ); + ]; } $this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams); if ($context == 'feeAmount') { - $maxParams = array( + $maxParams = [ 'entity_id' => $params['id'], 'entity_table' => 'civicrm_contribution', - ); + ]; $maxTrxn = current(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($maxParams, TRUE)); - $trxnParams = array( + $trxnParams = [ 'id' => $maxTrxn['financial_trxn_id'], - ); - $compareParams = array( + ]; + $compareParams = [ 'to_financial_account_id' => 5, 'from_financial_account_id' => 6, 'total_amount' => 50, 'status_id' => 1, - ); + ]; $trxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['id'], 'DESC'); $this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams, $compareParams); - $fitemParams = array( + $fitemParams = [ 'entity_id' => $trxnId['financialTrxnId'], 'entity_table' => 'civicrm_financial_trxn', - ); - $compareParams = array( + ]; + $compareParams = [ 'amount' => 50, 'status_id' => 1, 'financial_account_id' => 5, - ); + ]; $this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams); } // This checks that empty Sales tax rows are not being created. If for any reason it needs to be removed the // line should be copied into all the functions that call this function & evaluated there // Be really careful not to remove or bypass this without ensuring stray rows do not re-appear // when calling completeTransaction or repeatTransaction. - $this->callAPISuccessGetCount('FinancialItem', array('description' => 'Sales Tax', 'amount' => 0), 0); + $this->callAPISuccessGetCount('FinancialItem', ['description' => 'Sales Tax', 'amount' => 0], 0); } /** @@ -2871,7 +2909,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) protected function cleanUpSetUpIDs() { foreach ($this->setupIDs as $entity => $id) { try { - civicrm_api3($entity, 'delete', array('id' => $id, 'skip_undelete' => 1)); + civicrm_api3($entity, 'delete', ['id' => $id, 'skip_undelete' => 1]); } catch (CiviCRM_API3_Exception $e) { // This is a best-effort cleanup function, ignore. @@ -2886,12 +2924,12 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * * @return array */ - protected function createFinancialType($params = array()) { + protected function createFinancialType($params = []) { $params = array_merge($params, - array( + [ 'name' => 'Financial-Type -' . substr(sha1(rand()), 0, 7), 'is_active' => 1, - ) + ] ); return $this->callAPISuccess('FinancialType', 'create', $params); } @@ -2904,12 +2942,12 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * * @return int */ - protected function createPaymentInstrument($params = array(), $financialAccountName = 'Donation') { - $params = array_merge(array( + protected function createPaymentInstrument($params = [], $financialAccountName = 'Donation') { + $params = array_merge([ 'label' => 'Payment Instrument -' . substr(sha1(rand()), 0, 7), 'option_group_id' => 'payment_instrument', 'is_active' => 1, - ), $params); + ], $params); $newPaymentInstrument = $this->callAPISuccess('OptionValue', 'create', $params)['id']; $relationTypeID = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); @@ -2928,10 +2966,10 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) /** * Enable Tax and Invoicing */ - protected function enableTaxAndInvoicing($params = array()) { + protected function enableTaxAndInvoicing($params = []) { // Enable component contribute setting $contributeSetting = array_merge($params, - array( + [ 'invoicing' => 1, 'invoice_prefix' => 'INV_', 'credit_notes_prefix' => 'CN_', @@ -2941,7 +2979,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'is_email_pdf' => 1, 'tax_term' => 'Sales Tax', 'tax_display_settings' => 'Inclusive', - ) + ] ); return Civi::settings()->set('contribution_invoice_settings', $contributeSetting); } @@ -2949,15 +2987,15 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) /** * Enable Tax and Invoicing */ - protected function disableTaxAndInvoicing($params = array()) { + protected function disableTaxAndInvoicing($params = []) { if (!empty(\Civi::$statics['CRM_Core_PseudoConstant']) && isset(\Civi::$statics['CRM_Core_PseudoConstant']['taxRates'])) { unset(\Civi::$statics['CRM_Core_PseudoConstant']['taxRates']); } // Enable component contribute setting $contributeSetting = array_merge($params, - array( + [ 'invoicing' => 0, - ) + ] ); return Civi::settings()->set('contribution_invoice_settings', $contributeSetting); } @@ -2970,20 +3008,20 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * @return obj */ protected function relationForFinancialTypeWithFinancialAccount($financialTypeId) { - $params = array( + $params = [ 'name' => 'Sales tax account ' . substr(sha1(rand()), 0, 4), 'financial_account_type_id' => key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Liability' ")), 'is_deductible' => 1, 'is_tax' => 1, 'tax_rate' => 10, 'is_active' => 1, - ); + ]; $account = CRM_Financial_BAO_FinancialAccount::add($params); - $entityParams = array( + $entityParams = [ 'entity_table' => 'civicrm_financial_type', 'entity_id' => $financialTypeId, 'account_relationship' => key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' ")), - ); + ]; // set tax rate (as 10) for provided financial type ID to static variable, later used to fetch tax rates of all financial types \Civi::$statics['CRM_Core_PseudoConstant']['taxRates'][$financialTypeId] = 10; @@ -3010,9 +3048,9 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * @param $entity * @param array $params */ - public function createPriceSetWithPage($entity = NULL, $params = array()) { - $membershipTypeID = $this->membershipTypeCreate(array('name' => 'Special')); - $contributionPageResult = $this->callAPISuccess('contribution_page', 'create', array( + public function createPriceSetWithPage($entity = NULL, $params = []) { + $membershipTypeID = $this->membershipTypeCreate(['name' => 'Special']); + $contributionPageResult = $this->callAPISuccess('contribution_page', 'create', [ 'title' => "Test Contribution Page", 'financial_type_id' => 1, 'currency' => 'NZD', @@ -3020,22 +3058,22 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'is_pay_later' => 1, 'is_monetary' => TRUE, 'is_email_receipt' => FALSE, - )); - $priceSet = $this->callAPISuccess('price_set', 'create', array( + ]); + $priceSet = $this->callAPISuccess('price_set', 'create', [ 'is_quick_config' => 0, 'extends' => 'CiviMember', 'financial_type_id' => 1, 'title' => 'my Page', - )); + ]); $priceSetID = $priceSet['id']; CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID); - $priceField = $this->callAPISuccess('price_field', 'create', array( + $priceField = $this->callAPISuccess('price_field', 'create', [ 'price_set_id' => $priceSetID, 'label' => 'Goat Breed', 'html_type' => 'Radio', - )); - $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( + ]); + $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', [ 'price_set_id' => $priceSetID, 'price_field_id' => $priceField['id'], 'label' => 'Long Haired Goat', @@ -3043,9 +3081,9 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'financial_type_id' => 'Donation', 'membership_type_id' => $membershipTypeID, 'membership_num_terms' => 1, - )); - $this->_ids['price_field_value'] = array($priceFieldValue['id']); - $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( + ]); + $this->_ids['price_field_value'] = [$priceFieldValue['id']]; + $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', [ 'price_set_id' => $priceSetID, 'price_field_id' => $priceField['id'], 'label' => 'Shoe-eating Goat', @@ -3053,28 +3091,30 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'financial_type_id' => 'Donation', 'membership_type_id' => $membershipTypeID, 'membership_num_terms' => 2, - )); + ]); $this->_ids['price_field_value'][] = $priceFieldValue['id']; - $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( + $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', [ 'price_set_id' => $priceSetID, 'price_field_id' => $priceField['id'], 'label' => 'Shoe-eating Goat', 'amount' => 10, 'financial_type_id' => 'Donation', - )); + ]); $this->_ids['price_field_value']['cont'] = $priceFieldValue['id']; $this->_ids['price_set'] = $priceSetID; $this->_ids['contribution_page'] = $contributionPageResult['id']; - $this->_ids['price_field'] = array($priceField['id']); + $this->_ids['price_field'] = [$priceField['id']]; $this->_ids['membership_type'] = $membershipTypeID; } /** * Only specified contact returned. + * * @implements CRM_Utils_Hook::aclWhereClause + * * @param $type * @param $tables * @param $whereTables @@ -3109,16 +3149,16 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) if ($op == 'create' && $objectName == 'Individual') { CRM_Core_DAO::executeQuery( "UPDATE civicrm_contact SET nick_name = 'munged' WHERE id = %1", - array( - 1 => array($objectId, 'Integer'), - ) + [ + 1 => [$objectId, 'Integer'], + ] ); } if ($op == 'edit' && $objectName == 'Participant') { - $params = array( - 1 => array($objectId, 'Integer'), - ); + $params = [ + 1 => [$objectId, 'Integer'], + ]; $query = "UPDATE civicrm_participant SET source = 'Post Hook Update' WHERE id = %1"; CRM_Core_DAO::executeQuery($query, $params); } @@ -3154,7 +3194,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * @return array */ public function getThousandSeparators() { - return array(array('.'), array(',')); + return [['.'], [',']]; } /** @@ -3206,12 +3246,12 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * Enable multilingual. */ public function enableMultilingual() { - $this->callAPISuccess('Setting', 'create', array( + $this->callAPISuccess('Setting', 'create', [ 'lcMessages' => 'en_US', - 'languageLimit' => array( + 'languageLimit' => [ 'en_US' => 1, - ), - )); + ], + ]); CRM_Core_I18n_Schema::makeMultilingual('en_US'); @@ -3221,6 +3261,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) /** * Setup or clean up SMS tests + * * @param bool $teardown * * @throws \CiviCRM_API3_Exception @@ -3230,20 +3271,20 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) // Option value params for CiviTestSMSProvider $groupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'sms_provider_name', 'id', 'name'); - $params = array( + $params = [ 'option_group_id' => $groupID, 'label' => 'unittestSMS', 'value' => 'unit.test.sms', - 'name' => 'CiviTestSMSProvider', + 'name' => 'CiviTestSMSProvider', 'is_default' => 1, - 'is_active' => 1, - 'version' => 3, - ); + 'is_active' => 1, + 'version' => 3, + ]; if ($teardown) { // Test completed, delete provider $providerOptionValueResult = civicrm_api3('option_value', 'get', $params); - civicrm_api3('option_value', 'delete', array('id' => $providerOptionValueResult['id'])); + civicrm_api3('option_value', 'delete', ['id' => $providerOptionValueResult['id']]); return; } -- 2.25.1