diff --git a/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php b/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php index 9537227ccb25f7572cee5949cda652ab45ca3511..b20e1b844e3945b58312a2ade8361e7803bbfa6f 100644 --- a/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php +++ b/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php @@ -196,13 +196,6 @@ protected function getExpectedCacheContexts(array $sparse_fieldset = NULL) { return $contexts; } - /** - * {@inheritdoc} - */ - public function testRelated() { - $this->markTestSkipped('Remove this in https://www.drupal.org/project/drupal/issues/2940339'); - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/tests/src/Functional/CommentTest.php b/core/modules/jsonapi/tests/src/Functional/CommentTest.php index be7545835787ad667cba02e724d3b73b78532344..b293e91b3d5470893120c0c02bae4f77365df1a0 100644 --- a/core/modules/jsonapi/tests/src/Functional/CommentTest.php +++ b/core/modules/jsonapi/tests/src/Functional/CommentTest.php @@ -388,13 +388,6 @@ protected static function entityAccess(EntityInterface $entity, $operation, Acco return parent::entityAccess($entity, $operation, $account); } - /** - * {@inheritdoc} - */ - public function testRelated() { - $this->markTestSkipped('Remove this in https://www.drupal.org/project/drupal/issues/2940339'); - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php b/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php index f5e2fcd72491703403a7ddc70424bd0f695b6b0b..d11af84848de251e2cc6d15ee637694f07e79e62 100644 --- a/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php +++ b/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php @@ -172,13 +172,6 @@ protected function getExpectedUnauthorizedAccessMessage($method) { } } - /** - * {@inheritdoc} - */ - public function testRelated() { - $this->markTestSkipped('Remove this in https://www.drupal.org/project/drupal/issues/2940339'); - } - /** * {@inheritdoc} */ diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php index 94e80f589eb0a3ca36fd180057aee2be9fed185b..33d230b7f4437d44db6abead5df27392ea8aa477 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php @@ -1839,9 +1839,13 @@ protected function getExpectedRelatedResponse($relationship_field_name, array $r 'url.site', ], $this->entity->getEntityType()->isRevisionable() ? ['url.query_args:resourceVersion'] : []); $cacheability = (new CacheableMetadata())->addCacheContexts($cache_contexts)->addCacheTags(['http_response']); - $related_response = isset($relationship_document['errors']) - ? $relationship_response - : (new CacheableResourceResponse(static::getEmptyCollectionResponse(!is_null($relationship_document['data']), $self_link)->getResponseData()))->addCacheableDependency($cacheability); + if (isset($relationship_document['errors'])) { + $related_response = $relationship_response; + } + else { + $cardinality = is_null($relationship_document['data']) ? 1 : -1; + $related_response = (new CacheableResourceResponse(static::getEmptyCollectionResponse($cardinality, $self_link)->getResponseData()))->addCacheableDependency($cacheability); + } } else { $is_to_one_relationship = static::isResourceIdentifier($relationship_document['data']); @@ -1857,7 +1861,8 @@ protected function getExpectedRelatedResponse($relationship_field_name, array $r $related_response = static::toCollectionResourceResponse($individual_responses, $self_link, !$is_to_one_relationship); } else { - $related_response = static::getEmptyCollectionResponse(!$is_to_one_relationship, $self_link); + $cardinality = $is_to_one_relationship ? 1 : -1; + $related_response = static::getEmptyCollectionResponse($cardinality, $self_link); } } $related_response->addCacheableDependency($relationship_response->getCacheableMetadata()); diff --git a/core/modules/jsonapi/tests/src/Functional/TermTest.php b/core/modules/jsonapi/tests/src/Functional/TermTest.php index efb59122a4b66bc696516b0091565943f53fa266..d0f722df1979d8aadff8fafac78e39b1dca5c18a 100644 --- a/core/modules/jsonapi/tests/src/Functional/TermTest.php +++ b/core/modules/jsonapi/tests/src/Functional/TermTest.php @@ -469,13 +469,6 @@ public function providerTestGetIndividualTermWithParent() { ]; } - /** - * {@inheritdoc} - */ - public function testRelated() { - $this->markTestSkipped('Remove this in https://www.drupal.org/project/drupal/issues/2940339'); - } - /** * {@inheritdoc} */