From e45836d7574a3a0429d0e3e54ced89b65a8d4241 Mon Sep 17 00:00:00 2001 From: catch <6915-catch@users.noreply.drupalcode.org> Date: Thu, 23 Jan 2025 10:05:31 +0000 Subject: [PATCH] Issue #3495968 by nikolay shapovalov, berdir, smustgrave, quietone: Move entity_test_entity_types from entity_test.module --- .../Functional/EntityDisplayFormBaseTest.php | 3 +- .../modules/entity_test/entity_test.install | 3 +- .../modules/entity_test/entity_test.module | 60 ------------------- .../entity_test/src/EntityTestHelper.php | 57 ++++++++++++++++++ .../entity_test/src/EntityTestTypesFilter.php | 21 +++++++ .../entity_test/src/Hook/EntityTestHooks.php | 3 +- .../Derivative/EntityTestLocalTasks.php | 4 +- .../src/Routing/EntityTestRoutes.php | 4 +- .../src/Functional/Entity/EntityFormTest.php | 6 +- .../Functional/Entity/EntityRevisionsTest.php | 4 +- .../KernelTests/Core/Entity/EntityApiTest.php | 5 +- .../Entity/EntityFieldDefaultValueTest.php | 3 +- .../Core/Entity/EntityFieldTest.php | 17 +++--- .../Core/Entity/EntityLanguageTestBase.php | 5 +- .../Entity/EntityRevisionTranslationTest.php | 4 +- .../Core/Entity/EntityTranslationTest.php | 12 ++-- .../Core/Entity/EntityUUIDTest.php | 6 +- .../Core/Entity/EntityValidationTest.php | 3 +- 18 files changed, 130 insertions(+), 90 deletions(-) create mode 100644 core/modules/system/tests/modules/entity_test/src/EntityTestHelper.php create mode 100644 core/modules/system/tests/modules/entity_test/src/EntityTestTypesFilter.php diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayFormBaseTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayFormBaseTest.php index bdf6000289f2..e9799236535c 100644 --- a/core/modules/field_ui/tests/src/Functional/EntityDisplayFormBaseTest.php +++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayFormBaseTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\field_ui\Functional; +use Drupal\entity_test\EntityTestHelper; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\Tests\BrowserTestBase; @@ -31,7 +32,7 @@ class EntityDisplayFormBaseTest extends BrowserTestBase { protected function setUp(): void { parent::setUp(); - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { // Auto-create fields for testing. FieldStorageConfig::create([ 'entity_type' => $entity_type, diff --git a/core/modules/system/tests/modules/entity_test/entity_test.install b/core/modules/system/tests/modules/entity_test/entity_test.install index 1c8d21cbdf70..0e61b7f4ff9b 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.install +++ b/core/modules/system/tests/modules/entity_test/entity_test.install @@ -7,6 +7,7 @@ declare(strict_types=1); +use Drupal\entity_test\EntityTestHelper; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldConfig; @@ -14,7 +15,7 @@ * Implements hook_install(). */ function entity_test_install(): void { - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { // Auto-create fields for testing. FieldStorageConfig::create([ 'entity_type' => $entity_type, diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 387830f24643..66667dfd7253 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -11,66 +11,6 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Form\FormStateInterface; -/** - * Filter that limits test entity list to revisable ones. - */ -const ENTITY_TEST_TYPES_REVISABLE = 1; - -/** - * Filter that limits test entity list to multilingual ones. - */ -const ENTITY_TEST_TYPES_MULTILINGUAL = 2; - -/** - * Filter that limits test entity list to ones that can be routed. - */ -const ENTITY_TEST_TYPES_ROUTING = 3; - -/** - * Returns a list of test entity types. - * - * The returned entity types are one for each available entity storage type: - * - The plain entity_test type supports neither revisions nor multilingual - * properties. - * - The entity_test_mul type supports multilingual properties. - * - The entity_test_rev type supports revisions. - * - The entity_test_mulrev type supports both revisions and multilingual - * properties. - * - * @param int $filter - * Either ENTITY_TEST_TYPES_REVISABLE to only return revisable entity types or - * ENTITY_TEST_TYPES_MULTILINGUAL to only return multilingual ones. Defaults - * to NULL, which returns all. - * - * @return array - * List with entity_types. - */ -function entity_test_entity_types($filter = NULL) { - $types = []; - if ($filter === NULL || $filter === ENTITY_TEST_TYPES_ROUTING) { - $types[] = 'entity_test'; - } - if ($filter != ENTITY_TEST_TYPES_REVISABLE) { - $types[] = 'entity_test_mul'; - $types[] = 'entity_test_mul_langcode_key'; - $types[] = 'entity_test_mul_changed'; - } - if ($filter != ENTITY_TEST_TYPES_MULTILINGUAL) { - $types[] = 'entity_test_rev'; - } - if ($filter === ENTITY_TEST_TYPES_ROUTING) { - $types[] = 'entity_test_base_field_display'; - $types[] = 'entity_test_string_id'; - $types[] = 'entity_test_uuid_id'; - $types[] = 'entity_test_no_id'; - $types[] = 'entity_test_mul_with_bundle'; - } - $types[] = 'entity_test_mulrev'; - $types[] = 'entity_test_mulrev_changed'; - - return array_combine($types, $types); -} - /** * Creates a new bundle for entity_test entities. * diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestHelper.php b/core/modules/system/tests/modules/entity_test/src/EntityTestHelper.php new file mode 100644 index 000000000000..1cc35789e19c --- /dev/null +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestHelper.php @@ -0,0 +1,57 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\entity_test; + +/** + * Class for the entity API providing several entity types for testing. + */ +class EntityTestHelper { + + /** + * Returns a list of test entity types. + * + * The returned entity types are one for each available entity storage type: + * - The plain entity_test type supports neither revisions nor multilingual + * properties. + * - The entity_test_mul type supports multilingual properties. + * - The entity_test_rev type supports revisions. + * - The entity_test_mulrev type supports both revisions and multilingual + * properties. + * + * @param int $filter + * Either EntityTestTypesFilter::Revisable to only return revisable entity types or + * EntityTestTypesFilter::Multilingual to only return multilingual ones. Defaults + * to NULL, which returns all. + * + * @return array + * List with entity_types. + */ + public static function getEntityTypes($filter = NULL): array { + $types = []; + if ($filter === NULL || $filter === EntityTestTypesFilter::Routing) { + $types[] = 'entity_test'; + } + if ($filter != EntityTestTypesFilter::Revisable) { + $types[] = 'entity_test_mul'; + $types[] = 'entity_test_mul_langcode_key'; + $types[] = 'entity_test_mul_changed'; + } + if ($filter != EntityTestTypesFilter::Multilingual) { + $types[] = 'entity_test_rev'; + } + if ($filter === EntityTestTypesFilter::Routing) { + $types[] = 'entity_test_base_field_display'; + $types[] = 'entity_test_string_id'; + $types[] = 'entity_test_uuid_id'; + $types[] = 'entity_test_no_id'; + $types[] = 'entity_test_mul_with_bundle'; + } + $types[] = 'entity_test_mulrev'; + $types[] = 'entity_test_mulrev_changed'; + + return array_combine($types, $types); + } + +} diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestTypesFilter.php b/core/modules/system/tests/modules/entity_test/src/EntityTestTypesFilter.php new file mode 100644 index 000000000000..f7c47a4963d2 --- /dev/null +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestTypesFilter.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\entity_test; + +/** + * Enumeration of test entity types filter. + */ +enum EntityTestTypesFilter: int { + + // Filter that limits test entity list to revisable ones. + case Revisable = 1; + + // Filter that limits test entity list to multilingual ones. + case Multilingual = 2; + + // Filter that limits test entity list to ones that can be routed. + case Routing = 3; + +} diff --git a/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php b/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php index c6eef6663292..bdaf0416b837 100644 --- a/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php +++ b/core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php @@ -21,6 +21,7 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Hook\Attribute\Hook; +use Drupal\entity_test\EntityTestHelper; /** * Hook implementations for entity_test. @@ -36,7 +37,7 @@ class EntityTestHooks { public function entityTypeAlter(array &$entity_types) : void { $state = \Drupal::state(); /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */ - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { // Optionally specify a translation handler for testing translations. if ($state->get('entity_test.translation')) { $translation = $entity_types[$entity_type]->get('translation'); diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php index e13e6e457274..528a43ddbe4f 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php @@ -5,6 +5,8 @@ namespace Drupal\entity_test\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DeriverBase; +use Drupal\entity_test\EntityTestHelper; +use Drupal\entity_test\EntityTestTypesFilter; /** * Defines the local tasks for all the entity_test entities. @@ -16,7 +18,7 @@ class EntityTestLocalTasks extends DeriverBase { */ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = []; - $types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING); + $types = EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Routing); foreach ($types as $entity_type) { $this->derivatives[$entity_type . '.canonical'] = []; diff --git a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php index 39c49a3998b9..6481ccb428e1 100644 --- a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php +++ b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php @@ -4,6 +4,8 @@ namespace Drupal\entity_test\Routing; +use Drupal\entity_test\EntityTestHelper; +use Drupal\entity_test\EntityTestTypesFilter; use Symfony\Component\Routing\Route; /** @@ -18,7 +20,7 @@ class EntityTestRoutes { * An array of route objects. */ public function routes() { - $types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING); + $types = EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Routing); $routes = []; foreach ($types as $entity_type_id) { diff --git a/core/modules/system/tests/src/Functional/Entity/EntityFormTest.php b/core/modules/system/tests/src/Functional/Entity/EntityFormTest.php index ae6f7243ecff..cb555a811ada 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityFormTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityFormTest.php @@ -7,6 +7,8 @@ use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Entity\Entity\EntityFormMode; use Drupal\entity_test\Entity\EntityTest; +use Drupal\entity_test\EntityTestHelper; +use Drupal\entity_test\EntityTestTypesFilter; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\BrowserTestBase; @@ -54,7 +56,7 @@ protected function setUp(): void { */ public function testFormCRUD(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestFormCRUD($entity_type); } } @@ -64,7 +66,7 @@ public function testFormCRUD(): void { */ public function testMultilingualFormCRUD(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types(ENTITY_TEST_TYPES_MULTILINGUAL) as $entity_type) { + foreach (EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Multilingual) as $entity_type) { $this->doTestMultilingualFormCRUD($entity_type); } } diff --git a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php index 7101989b65ef..199daa93c7d2 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php @@ -5,6 +5,8 @@ namespace Drupal\Tests\system\Functional\Entity; use Drupal\entity_test\Entity\EntityTestMulRev; +use Drupal\entity_test\EntityTestHelper; +use Drupal\entity_test\EntityTestTypesFilter; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\language\Entity\ConfigurableLanguage; @@ -57,7 +59,7 @@ protected function setUp(): void { public function testRevisions(): void { // All revisable entity variations have to have the same results. - foreach (entity_test_entity_types(ENTITY_TEST_TYPES_REVISABLE) as $entity_type) { + foreach (EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Revisable) as $entity_type) { $this->runRevisionsTests($entity_type); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php index 07ae276d8e7b..f4f1b70eac52 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php @@ -7,6 +7,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Entity\EntityStorageException; use Drupal\entity_test\Entity\EntityTest; +use Drupal\entity_test\EntityTestHelper; use Drupal\user\UserInterface; /** @@ -22,7 +23,7 @@ class EntityApiTest extends EntityKernelTestBase { protected function setUp(): void { parent::setUp(); - foreach (entity_test_entity_types() as $entity_type_id) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type_id) { // The entity_test schema is installed by the parent. if ($entity_type_id != 'entity_test') { $this->installEntitySchema($entity_type_id); @@ -35,7 +36,7 @@ protected function setUp(): void { */ public function testCRUD(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->assertCRUD($entity_type, $this->createUser()); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php index 4641f58f40ae..08af66e967a8 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php @@ -5,6 +5,7 @@ namespace Drupal\KernelTests\Core\Entity; use Drupal\Component\Uuid\Uuid; +use Drupal\entity_test\EntityTestHelper; /** * Tests default values for entity fields. @@ -34,7 +35,7 @@ protected function setUp(): void { */ public function testDefaultValues(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->assertDefaultValues($entity_type); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php index fe70fda8b572..5e34ef2dc178 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php @@ -23,6 +23,7 @@ use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTestComputedField; use Drupal\entity_test\Entity\EntityTestRev; +use Drupal\entity_test\EntityTestHelper; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; @@ -59,7 +60,7 @@ class EntityFieldTest extends EntityKernelTestBase { protected function setUp(): void { parent::setUp(); - foreach (entity_test_entity_types() as $entity_type_id) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type_id) { // The entity_test schema is installed by the parent. if ($entity_type_id != 'entity_test') { $this->installEntitySchema($entity_type_id); @@ -136,7 +137,7 @@ public function testFieldEntityRevisionWrite(): void { */ public function testReadWrite(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestReadWrite($entity_type); } } @@ -402,7 +403,7 @@ protected function doTestReadWrite($entity_type): void { */ public function testSave(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestSave($entity_type); } } @@ -439,7 +440,7 @@ protected function doTestSave($entity_type): void { */ public function testIntrospection(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestIntrospection($entity_type); } } @@ -543,7 +544,7 @@ protected function doTestIntrospection($entity_type): void { */ public function testIterator(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestIterator($entity_type); } } @@ -582,7 +583,7 @@ protected function doTestIterator($entity_type): void { */ public function testDataStructureInterfaces(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestDataStructureInterfaces($entity_type); } } @@ -654,7 +655,7 @@ public function getContainedStrings(TypedDataInterface $wrapper, $depth, array & */ public function testDataTypes(): void { $types = \Drupal::typedDataManager()->getDefinitions(); - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->assertNotEmpty($types['entity:' . $entity_type]['class'], 'Entity data type registered.'); } // Check bundle types are provided as well. @@ -774,7 +775,7 @@ public function testEntityConstraintValidation(): void { */ public function testComputedProperties(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestComputedProperties($entity_type); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php index 3922e80da303..95b78ede4e96 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php @@ -4,6 +4,7 @@ namespace Drupal\KernelTests\Core\Entity; +use Drupal\entity_test\EntityTestHelper; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -54,7 +55,7 @@ protected function setUp(): void { $this->languageManager = $this->container->get('language_manager'); - foreach (entity_test_entity_types() as $entity_type_id) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type_id) { // The entity_test schema is installed by the parent. if ($entity_type_id != 'entity_test') { $this->installEntitySchema($entity_type_id); @@ -77,7 +78,7 @@ protected function setUp(): void { $this->untranslatableFieldName = $this->randomMachineName() . '_field_name'; // Create field fields in all entity variations. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { FieldStorageConfig::create([ 'field_name' => $this->fieldName, 'entity_type' => $entity_type, diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php index 3d75bf3b29d2..1ed5e387f848 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php @@ -6,6 +6,8 @@ use Drupal\entity_test\Entity\EntityTestMul; use Drupal\entity_test\Entity\EntityTestMulRev; +use Drupal\entity_test\EntityTestHelper; +use Drupal\entity_test\EntityTestTypesFilter; use Drupal\language\Entity\ConfigurableLanguage; /** @@ -174,7 +176,7 @@ public function testSetNewRevision(): void { $user = $this->createUser(); // All revisionable entity variations have to have the same results. - foreach (entity_test_entity_types(ENTITY_TEST_TYPES_REVISABLE) as $entity_type) { + foreach (EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Revisable) as $entity_type) { $this->installEntitySchema($entity_type); $storage = \Drupal::entityTypeManager()->getStorage($entity_type); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php index 35b18ce53ca3..e09aafb52ee0 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php @@ -8,6 +8,8 @@ use Drupal\Core\TypedData\TranslationStatusInterface; use Drupal\entity_test\Entity\EntityTestMul; use Drupal\entity_test\Entity\EntityTestMulRev; +use Drupal\entity_test\EntityTestHelper; +use Drupal\entity_test\EntityTestTypesFilter; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\language\Entity\ConfigurableLanguage; @@ -24,7 +26,7 @@ class EntityTranslationTest extends EntityLanguageTestBase { */ public function testEntityLanguageMethods(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->doTestEntityLanguageMethods($entity_type); } } @@ -144,7 +146,7 @@ protected function doTestEntityLanguageMethods($entity_type): void { */ public function testMultilingualProperties(): void { // Test all entity variations with data table support. - foreach (entity_test_entity_types(ENTITY_TEST_TYPES_MULTILINGUAL) as $entity_type) { + foreach (EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Multilingual) as $entity_type) { $this->doTestMultilingualProperties($entity_type); } } @@ -307,7 +309,7 @@ protected function doTestMultilingualProperties($entity_type): void { */ public function testEntityTranslationAPI(): void { // Test all entity variations with data table support. - foreach (entity_test_entity_types(ENTITY_TEST_TYPES_MULTILINGUAL) as $entity_type) { + foreach (EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Multilingual) as $entity_type) { $this->doTestEntityTranslationAPI($entity_type); } } @@ -575,7 +577,7 @@ protected function doTestEntityTranslationAPI($entity_type): void { */ public function testLanguageFallback(): void { // Test all entity variations with data table support. - foreach (entity_test_entity_types(ENTITY_TEST_TYPES_MULTILINGUAL) as $entity_type) { + foreach (EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Multilingual) as $entity_type) { $this->doTestLanguageFallback($entity_type); } } @@ -716,7 +718,7 @@ public function testFieldDefinitions(): void { */ public function testLanguageChange(): void { // Test all entity variations with data table support. - foreach (entity_test_entity_types(ENTITY_TEST_TYPES_MULTILINGUAL) as $entity_type) { + foreach (EntityTestHelper::getEntityTypes(EntityTestTypesFilter::Multilingual) as $entity_type) { $this->doTestLanguageChange($entity_type); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php index 984d8abca38e..dee6c23dff8e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php @@ -4,6 +4,8 @@ namespace Drupal\KernelTests\Core\Entity; +use Drupal\entity_test\EntityTestHelper; + /** * Tests creation, saving, and loading of entity UUIDs. * @@ -17,7 +19,7 @@ class EntityUUIDTest extends EntityKernelTestBase { protected function setUp(): void { parent::setUp(); - foreach (entity_test_entity_types() as $entity_type_id) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type_id) { // The entity_test schema is installed by the parent. if ($entity_type_id != 'entity_test') { $this->installEntitySchema($entity_type_id); @@ -30,7 +32,7 @@ protected function setUp(): void { */ public function testCRUD(): void { // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->assertCRUD($entity_type); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php index 7e0fdfbda573..54799c7be428 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Plugin\Validation\Constraint\CompositeConstraintBase; +use Drupal\entity_test\EntityTestHelper; use Drupal\language\Entity\ConfigurableLanguage; /** @@ -116,7 +117,7 @@ public function testValidation(): void { $this->assertContains('Drupal\Core\Validation\ConstraintManager', $cached_discovery_classes); // All entity variations have to have the same results. - foreach (entity_test_entity_types() as $entity_type) { + foreach (EntityTestHelper::getEntityTypes() as $entity_type) { $this->checkValidation($entity_type); } } -- GitLab