diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 41d9eec849..0fa178daf6 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -473,12 +473,17 @@ public function testGet() { if ($this->entity->getEntityType()->getLinkTemplates()) { $this->assertArrayHasKey('Link', $response->getHeaders()); $link_relation_type_manager = $this->container->get('plugin.manager.link_relation_type'); + // Filter out definitions that do not have a plugin. + // @see \Drupal\rest\Plugin\rest\resource\EntityResource::addLinkHeaders() + $link_relations = array_values(array_filter(array_keys($this->entity->getEntityType()->getLinkTemplates()), function ($relation_name) use ($link_relation_type_manager) { + return $link_relation_type_manager->hasDefinition($relation_name); + })); $expected_link_relation_headers = array_map(function ($relation_name) use ($link_relation_type_manager) { $link_relation_type = $link_relation_type_manager->createInstance($relation_name); return $link_relation_type->isRegistered() ? $link_relation_type->getRegisteredName() : $link_relation_type->getExtensionUri(); - }, array_keys($this->entity->getEntityType()->getLinkTemplates())); + }, $link_relations); $parse_rel_from_link_header = function ($value) use ($link_relation_type_manager) { $matches = []; if (preg_match('/rel="([^"]+)"/', $value, $matches) === 1) { 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 025cb5fc2f..d595d4a320 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -71,6 +71,7 @@ function entity_test_entity_types($filter = NULL) { $types[] = 'entity_test_base_field_display'; $types[] = 'entity_test_string_id'; $types[] = 'entity_test_no_id'; + $types[] = 'entity_test_mul_with_bundle'; } $types[] = 'entity_test_mulrev'; $types[] = 'entity_test_mulrev_changed'; @@ -199,7 +200,7 @@ function entity_test_entity_bundle_info() { $bundles = []; $entity_types = \Drupal::entityManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { - if ($entity_type->getProvider() == 'entity_test' && $entity_type_id != 'entity_test_with_bundle') { + if ($entity_type->getProvider() == 'entity_test' && !in_array($entity_type_id, ['entity_test_with_bundle', 'entity_test_mul_with_bundle'], TRUE)) { $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles') ?: [$entity_type_id => ['label' => 'Entity Test Bundle']]; } }