From 1e06a3ef3a596f145b857c329f4db59d856324ce Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 28 Aug 2020 15:04:07 +0100
Subject: [PATCH] Issue #3093757 by bbrala, vsujeetkumar, jofitz,
 ridhimaabrol24, Berdir, xjm: Test is marked skipped but shouldn't be anymore

---
 .../tests/src/Functional/BlockContentTest.php       |  7 -------
 .../jsonapi/tests/src/Functional/CommentTest.php    |  7 -------
 .../tests/src/Functional/MenuLinkContentTest.php    |  7 -------
 .../tests/src/Functional/ResourceTestBase.php       | 13 +++++++++----
 .../jsonapi/tests/src/Functional/TermTest.php       |  7 -------
 5 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php b/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
index 9537227ccb25..b20e1b844e39 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 be7545835787..b293e91b3d54 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 f5e2fcd72491..d11af84848de 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 94e80f589eb0..33d230b7f443 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 efb59122a4b6..d0f722df1979 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}
    */
-- 
GitLab