Verified Commit 8d95ff2f authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3082053 by vsujeetkumar, kristiaanvandeneynde, Wim Leers:...

Issue #3082053 by vsujeetkumar, kristiaanvandeneynde, Wim Leers: EntityResourceTestBase needlessly tests the caching layer

(cherry picked from commit f8b4d7a1)
parent 40602075
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -519,19 +519,18 @@ public function testGet() {
    // @see \Drupal\rest\EventSubscriber\ResourceResponseSubscriber::flattenResponse()
    $cache_items = $this->container->get('database')
      ->select('cache_dynamic_page_cache', 'c')
      ->fields('c', ['cid', 'data'])
      ->fields('c', ['data'])
      ->condition('c.cid', '%[route]=rest.%', 'LIKE')
      ->execute()
      ->fetchAllAssoc('cid');
      ->fetchAll();
    if (!$is_cacheable_by_dynamic_page_cache) {
      $this->assertCount(0, $cache_items);
    }
    else {
      $this->assertCount(2, $cache_items);
      $found_cache_redirect = FALSE;
      $this->assertLessThanOrEqual(2, count($cache_items));
      $found_cached_200_response = FALSE;
      $other_cached_responses_are_4xx = TRUE;
      foreach ($cache_items as $cid => $cache_item) {
      foreach ($cache_items as $cache_item) {
        $cached_data = unserialize($cache_item->data);
        if (!isset($cached_data['#cache_redirect'])) {
          $cached_response = $cached_data['#response'];
@@ -544,11 +543,7 @@ public function testGet() {
          $this->assertNotInstanceOf(ResourceResponseInterface::class, $cached_response);
          $this->assertInstanceOf(CacheableResponseInterface::class, $cached_response);
        }
        else {
          $found_cache_redirect = TRUE;
        }
      }
      $this->assertTrue($found_cache_redirect);
      $this->assertTrue($found_cached_200_response);
      $this->assertTrue($other_cached_responses_are_4xx);
    }