Commit 849ac823 authored by eileen's avatar eileen

[REF] Replace CRM_Utils_Array::value with ?? in variable assignments

Partial of  #16768 - only contains test lines which I don't think need individual review
parent c21afdf7
......@@ -611,7 +611,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
$this->assertEquals(1, $values['noteTotalCount'], 'Check for total note count');
foreach ($values['note'] as $key => $val) {
$retrieveNote = CRM_Utils_Array::value('note', $val);
$retrieveNote = $val['note'] ?? NULL;
//check the note value
$this->assertEquals($params['note'], $retrieveNote, 'Check for note');
}
......
......@@ -312,14 +312,14 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase {
$result = civicrm_api3('Address', 'create', $params);
$value = array_pop($result['values']);
$street_number = CRM_Utils_Array::value('street_number', $value);
$street_number = $value['street_number'] ?? NULL;
$this->assertEquals($street_number, '54');
// Ensure street parsing does not happen if disabled.
$this->setStreetAddressParsing(FALSE);
$result = civicrm_api3('Address', 'create', $params);
$value = array_pop($result['values']);
$street_number = CRM_Utils_Array::value('street_number', $value);
$street_number = $value['street_number'] ?? NULL;
$this->assertEmpty($street_number);
}
......
......@@ -49,7 +49,7 @@ class CRM_Core_Page_AJAXTest extends CiviUnitTestCase {
foreach ($cases as $case) {
list ($type, $className, $expectedResult) = $case;
$methodName = CRM_Utils_Array::value(3, $case);
$methodName = $case[3] ?? NULL;
$actualResult = CRM_Core_Page_AJAX::checkAuthz($type, $className, $methodName);
if ($methodName) {
$this->assertEquals($expectedResult, $actualResult,
......
......@@ -75,8 +75,8 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase {
// -- processing priceSet using the BAO
$lineItems = [];
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$feeBlock = CRM_Utils_Array::value('fields', $priceSet);
$priceSet = $priceSet[$priceSetId] ?? NULL;
$feeBlock = $priceSet['fields'] ?? NULL;
$params['price_2'] = $feeTotal;
$tempParams = $params;
......
......@@ -71,8 +71,8 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase {
$this->_priceSetID = $this->priceSetCreate();
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $this->_priceSetID);
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->_priceSetID, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($this->_priceSetID, $priceSet);
$this->_feeBlock = CRM_Utils_Array::value('fields', $priceSet);
$priceSet = $priceSet[$this->_priceSetID] ?? NULL;
$this->_feeBlock = $priceSet['fields'] ?? NULL;
}
/**
......@@ -376,8 +376,8 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase {
$this->_priceSetID = $this->priceSetCreate('Text');
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $this->_priceSetID);
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->_priceSetID, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($this->_priceSetID, $priceSet);
$this->_feeBlock = CRM_Utils_Array::value('fields', $priceSet);
$priceSet = $priceSet[$this->_priceSetID] ?? NULL;
$this->_feeBlock = $priceSet['fields'] ?? NULL;
$params = [
'send_receipt' => 1,
......
......@@ -348,7 +348,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase {
'limit' => 0,
],
]);
$result = CRM_Utils_Array::value('values', $membershipTypesResult, NULL);
$result = $membershipTypesResult['values'] ?? NULL;
$this->assertEquals(empty($result), FALSE, 'Verify membership types for organization.');
$membershipTypesResult = civicrm_api3('MembershipType', 'get', [
......@@ -357,7 +357,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase {
'limit' => 0,
],
]);
$result = CRM_Utils_Array::value('values', $membershipTypesResult, NULL);
$result = $membershipTypesResult['values'] ?? NULL;
$this->assertEquals(empty($result), TRUE, 'Verify membership types for organization.');
$this->membershipTypeDelete(['id' => $membershipType->id]);
......
......@@ -28,7 +28,7 @@ class CiviTestSMSProvider extends CRM_SMS_Provider {
$providerID = $provider['id'];
}
else {
$providerID = CRM_Utils_Array::value('provider_id', $providerParams);
$providerID = $providerParams['provider_id'] ?? NULL;
}
$skipAuth = $providerID ? FALSE : TRUE;
$cacheKey = (int) $providerID;
......
......@@ -1064,8 +1064,8 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase {
$this->priceSetID = $this->ids['PriceSet'][] = $this->eventPriceSetCreate(55, 0, 'Radio', $options);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $event['id'], $this->priceSetID);
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->priceSetID, TRUE, FALSE);
$priceSet = CRM_Utils_Array::value($this->priceSetID, $priceSet);
$this->eventFeeBlock = CRM_Utils_Array::value('fields', $priceSet);
$priceSet = $priceSet[$this->priceSetID] ?? NULL;
$this->eventFeeBlock = $priceSet['fields'] ?? NULL;
return $event;
}
......@@ -1927,7 +1927,7 @@ VALUES
else {
$keys[CRM_Utils_Array::value('name', $settings, $field)] = CRM_Utils_Array::value('name', $settings, $field);
}
$type = CRM_Utils_Array::value('type', $settings);
$type = $settings['type'] ?? NULL;
if ($type == CRM_Utils_Type::T_DATE) {
$dateFields[] = $settings['name'];
// we should identify both real names & unique names as dates
......
......@@ -2049,8 +2049,8 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
*/
public function hook_civicrm_alterPaymentProcessorParams($paymentObj, &$rawParams, &$cookedParams) {
// Ensure total_amount are the same if they're both given.
$total_amount = CRM_Utils_Array::value('total_amount', $rawParams);
$amount = CRM_Utils_Array::value('amount', $rawParams);
$total_amount = $rawParams['total_amount'] ?? NULL;
$amount = $rawParams['amount'] ?? NULL;
if (!empty($total_amount) && !empty($amount) && $total_amount != $amount) {
throw new Exception("total_amount '$total_amount' and amount '$amount' differ.");
}
......
......@@ -286,11 +286,11 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
foreach ($memType as $rowCount => $type) {
$membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($type);
$fieldParams['option_id'] = [1 => $priceFieldValue['id']];
$fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype);
$fieldParams['option_label'][$rowCount] = $membetype['name'] ?? NULL;
$fieldParams['option_amount'][$rowCount] = $membetype['minimum_fee'] ?? 0;
$fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype);
$fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype);
$fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype);
$fieldParams['option_weight'][$rowCount] = $membetype['weight'] ?? NULL;
$fieldParams['option_description'][$rowCount] = $membetype['description'] ?? NULL;
$fieldParams['option_financial_type_id'][$rowCount] = $membetype['financial_type_id'] ?? NULL;
$fieldParams['membership_type_id'][$rowCount] = $type;
}
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment