From 6998c192dbdd72bb4a144aa8652cd4c107a70a6f Mon Sep 17 00:00:00 2001 From: colemanw Date: Mon, 15 May 2023 13:09:08 -0400 Subject: [PATCH] Apiv4 - Test fixes after moving component api files to extensions --- .../phpunit/api/v4/Entity/ConformanceTest.php | 22 +++++++++---------- tests/phpunit/api/v4/Entity/EntityTest.php | 10 --------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/tests/phpunit/api/v4/Entity/ConformanceTest.php b/tests/phpunit/api/v4/Entity/ConformanceTest.php index 38932ace75..f33baccef5 100644 --- a/tests/phpunit/api/v4/Entity/ConformanceTest.php +++ b/tests/phpunit/api/v4/Entity/ConformanceTest.php @@ -85,10 +85,6 @@ class ConformanceTest extends Api4TestBase implements HookInterface { * @throws \CRM_Core_Exception */ public function getEntitiesHitech(): array { - // Ensure all components are enabled so their entities show up - foreach (array_keys(\CRM_Core_Component::getComponents()) as $component) { - \CRM_Core_BAO_ConfigSetting::enableComponent($component); - } return $this->toDataProviderArray(Entity::get(FALSE)->execute()->column('name')); } @@ -102,20 +98,22 @@ class ConformanceTest extends Api4TestBase implements HookInterface { * @return array */ public function getEntitiesLotech(): array { - // TODO: Auto-scan required core extensions like search_kit - $manual['add'] = ['SearchDisplay', 'SearchSegment']; - $manual['remove'] = ['CustomValue']; + // Core + required core extensions + $directores = ['', 'ext/search_kit/', 'ext/civi_*/']; + $manual['remove'] = ['CustomValue', 'SKEntity']; $manual['transform'] = ['CiviCase' => 'Case']; $scanned = []; - $srcDir = dirname(__DIR__, 5); - foreach ((array) glob("$srcDir/Civi/Api4/*.php") as $name) { - $fileName = basename($name, '.php'); - $scanned[] = $manual['transform'][$fileName] ?? $fileName; + $baseDir = dirname(__DIR__, 5); + foreach ($directores as $directory) { + foreach ((array) glob("$baseDir/{$directory}Civi/Api4/*.php") as $name) { + $fileName = basename($name, '.php'); + $scanned[] = $manual['transform'][$fileName] ?? $fileName; + } } $names = array_diff( - array_unique(array_merge($scanned, $manual['add'])), + $scanned, $manual['remove'] ); diff --git a/tests/phpunit/api/v4/Entity/EntityTest.php b/tests/phpunit/api/v4/Entity/EntityTest.php index 904a1454e8..271e94cfca 100644 --- a/tests/phpunit/api/v4/Entity/EntityTest.php +++ b/tests/phpunit/api/v4/Entity/EntityTest.php @@ -19,7 +19,6 @@ namespace api\v4\Entity; -use Civi\API\Exception\NotImplementedException; use Civi\Api4\Entity; use api\v4\Api4TestBase; @@ -60,15 +59,6 @@ class EntityTest extends Api4TestBase { $this->assertArrayNotHasKey('Participant', $result, "Entity::get should not have Participant when CiviEvent disabled"); - // Trying to use a CiviEvent API will fail when component is disabled - try { - \Civi\Api4\Participant::get(FALSE)->execute(); - $this->fail(); - } - catch (NotImplementedException $e) { - $this->assertStringContainsString('CiviEvent', $e->getMessage()); - } - \CRM_Core_BAO_ConfigSetting::enableComponent('CiviEvent'); $result = Entity::get(FALSE) ->execute() -- 2.25.1