From 33974098b629fd49b66d893e0cb5cf8618b61cc5 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 18 Jun 2020 18:59:47 +1000 Subject: [PATCH] [REF] Fix PHP7.4 Test fails when we are accessing array keys when the value is not an array --- CRM/Contact/BAO/Query.php | 2 +- tests/phpunit/CRM/Core/BAO/CustomFieldTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 122c1ac3f8b6..8b8aac826ce2 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2049,7 +2049,7 @@ public function whereClause($isForcePrimaryEmailOnly = NULL) { $this->_params[$id][1] ); $this->_qill[0][] = ts("%1 %2 %3", [ - 1 => $field['title'], + 1 => $field['title'] ?? '', 2 => $qillop, 3 => $qillVal, ]); diff --git a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php index 8b55cfe182e8..103a5c7bdf72 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php @@ -216,13 +216,13 @@ public function testGetDisplayedValuesContactRef() { ]; $createdField = $this->callAPISuccess('customField', 'create', $params); $contact1 = $this->individualCreate(); - $contact2 = $this->individualCreate(['custom_' . $createdField['id'] => $contact1['id']]); - - $this->assertEquals($contact1['display_name'], CRM_Core_BAO_CustomField::displayValue($contact2['id'], $createdField['id'])); + $contact2 = $this->individualCreate(['custom_' . $createdField['id'] => $contact1]); + $contact1Details = $this->callAPISuccess('Contact', 'getsingle', ['id' => $contact1]); + $this->assertEquals($contact1Details['display_name'], CRM_Core_BAO_CustomField::displayValue($contact2, $createdField['id'])); $this->assertEquals("Bob", CRM_Core_BAO_CustomField::displayValue("Bob", $createdField['id'])); - $this->contactDelete($contact2['id']); - $this->contactDelete($contact1['id']); + $this->contactDelete($contact2); + $this->contactDelete($contact1); $this->customGroupDelete($customGroup['id']); }