From 0089ae228f583816737615991ac313b5f3b8c7bd Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 14 Jan 2022 11:54:51 -0800 Subject: [PATCH] (REF) CRM_Core_Resources - Limit visibility of `getEntityRefMetadata` Before ------ * `CRM_Core_Resources::getEntityRefMetadata()` is nominally `public`. * The only callers are within `CRM_Core_Resources` and `CRM_Core_ResourcesTest`. * It seems likely that the method was `public` to support that unit-test. * This seems like a weird place for the method to live. After ------ * `CRM_Core_Resources::getEntityRefMetadata()` no longer `public`. * The method is still in a weird place, but at least no one will expect it to remain there. --- CRM/Core/Resources.php | 2 +- tests/phpunit/CRM/Core/ResourcesTest.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 0e4485c6ad..07e870a378 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -496,7 +496,7 @@ class CRM_Core_Resources implements CRM_Core_Resources_CollectionAdderInterface * * @return array */ - public static function getEntityRefMetadata() { + protected static function getEntityRefMetadata() { $data = [ 'filters' => [], 'links' => [], diff --git a/tests/phpunit/CRM/Core/ResourcesTest.php b/tests/phpunit/CRM/Core/ResourcesTest.php index f9d2ebaabd..ac9ccda088 100644 --- a/tests/phpunit/CRM/Core/ResourcesTest.php +++ b/tests/phpunit/CRM/Core/ResourcesTest.php @@ -9,6 +9,8 @@ +--------------------------------------------------------------------+ */ +use Civi\Test\Invasive; + /** * Tests for linking to resource files * @group headless @@ -508,7 +510,7 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { */ public function testEntityRefFiltersHook() { CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_entityRefFilters', [$this, 'entityRefFilters']); - $data = CRM_Core_Resources::getEntityRefMetadata(); + $data = Invasive::call(['CRM_Core_Resources', 'getEntityRefMetadata']); $this->assertEquals(count($data['links']['Contact']), 4); $this->assertEquals(!empty($data['links']['Contact']['new_staff']), TRUE); } -- 2.25.1