From e51dca6404fe6275f3b20dede4d88cec0e0cef48 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 9 Mar 2020 14:17:10 +1300 Subject: [PATCH] Fix another instance of NULL being passed to CRM_Utils_Array::value Note that the test has only cosmetic changes picked up while running the test to identify the bug --- CRM/Core/PseudoConstant.php | 6 +++--- tests/phpunit/CRM/Activity/BAO/ActivityTest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 2c9dee0a09..2655544aaf 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -85,7 +85,7 @@ class CRM_Core_PseudoConstant { * RelationshipType * @var array */ - private static $relationshipType; + private static $relationshipType = []; /** * Civicrm groups that are not smart groups @@ -1006,9 +1006,9 @@ WHERE id = %1"; * @return array * array reference of all relationship types. */ - public static function &relationshipType($valueColumnName = 'label', $reset = FALSE, $isActive = 1) { + public static function relationshipType($valueColumnName = 'label', $reset = FALSE, $isActive = 1) { $cacheKey = $valueColumnName . '::' . $isActive; - if (!CRM_Utils_Array::value($cacheKey, self::$relationshipType) || $reset) { + if (!isset(self::$relationshipType[$cacheKey]) || $reset) { self::$relationshipType[$cacheKey] = []; //now we have name/label columns CRM-3336 diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 236be3c440..2c4a1a8092 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -8,6 +8,11 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { private $allowedContactsACL = []; + /** + * Set up for test. + * + * @throws \CiviCRM_API3_Exception + */ public function setUp() { parent::setUp(); $this->prepareForACLs(); @@ -17,6 +22,9 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { /** * Clean up after tests. + * + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ public function tearDown() { $tablesToTruncate = [ @@ -34,6 +42,8 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { /** * Test case for create() method. + * + * @throws \CRM_Core_Exception */ public function testCreate() { $contactId = $this->individualCreate(); @@ -73,6 +83,8 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { * Test case for getContactActivity() method. * * getContactActivity() method get activities detail for given target contact id. + * + * @throws \CRM_Core_Exception */ public function testGetContactActivity() { $contactId = $this->individualCreate(); -- 2.25.1