diff --git a/CRM/Upgrade/Incremental/php/FiveSixtyOne.php b/CRM/Upgrade/Incremental/php/FiveSixtyOne.php index 75534f010b41..1d1af3c2abac 100644 --- a/CRM/Upgrade/Incremental/php/FiveSixtyOne.php +++ b/CRM/Upgrade/Incremental/php/FiveSixtyOne.php @@ -9,7 +9,6 @@ +--------------------------------------------------------------------+ */ -use Civi\Api4\Contribution; use Civi\Api4\MappingField; /** @@ -129,10 +128,11 @@ public static function convertMappingFieldsToApi4StyleNames(): bool { 'contribution_check_number' => 'check_number', 'contribution_campaign_id' => 'campaign_id', ]; - $apiv4 = Contribution::getFields(FALSE)->addWhere('custom_field_id', '>', 0)->execute(); - foreach ($apiv4 as $apiv4Field) { - $fieldMap['custom_' . $apiv4Field['custom_field_id']] = $apiv4Field['name']; - } + $fieldMap += CRM_Core_DAO::executeQuery(' + SELECT CONCAT("custom_", fld.id) AS old, CONCAT(grp.name, ".", fld.name) AS new + FROM civicrm_custom_field fld, civicrm_custom_group grp + WHERE grp.id = fld.custom_group_id AND grp.extends = "Contribution" + ')->fetchMap('old', 'new'); // Update the mapped fields. foreach ($mappings as $mapping) { diff --git a/tests/phpunit/api/v4/Entity/ConformanceTest.php b/tests/phpunit/api/v4/Entity/ConformanceTest.php index bbce400a608b..8375c3702245 100644 --- a/tests/phpunit/api/v4/Entity/ConformanceTest.php +++ b/tests/phpunit/api/v4/Entity/ConformanceTest.php @@ -85,10 +85,6 @@ public function tearDown(): void { * @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 @@ public function getEntitiesHitech(): array { * @return array */ public function getEntitiesLotech(): array { - // TODO: Auto-scan required core extensions like search_kit - $manual['add'] = ['SearchDisplay', 'SearchSegment']; + // Core + required core extensions + $directores = ['', 'ext/search_kit/', 'ext/civi_*/']; $manual['remove'] = ['CustomValue']; $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 904a1454e8cb..271e94cfcaab 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 @@ public function testEntityComponent() { $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()