ResourceTestBase needlessly tests the caching layer

Created on 18 September 2019, over 4 years ago
Updated 15 February 2023, over 1 year ago

This is a clone of #3082053: EntityResourceTestBase needlessly tests the caching layer β†’ , because the class in question was seemingly copied from rest.module's EntityResourceTestBase. I'll copy the description here, though.

ResourceTestBase::testGetIndividual() has some very specific testing of how many cache redirects there should be stored in DynamicPageCacheSubscriber (which uses the render cache behind the scenes).

By testing the caching layer when you needn't, you are making it harder to make changes to said caching layer as seemingly unrelated tests such as this one will go red when you change how the cache works. See #2551419-130: Abstract RenderCache into a separate service that is capable of cache redirects in a non-render array-specific way β†’ for an example of how it breaks unrelated patches.

The fix here is to adapt the code introduced in #2877778: Harden test EntityResource + Dynamic Page Cache test coverage β†’ to simply check if there are any redirects, not how many there are. This allows us to adjust how many redirects the cache might introduce without having seemingly unrelated test fails occur.

I'm still not happy that it tests whether the response is a redirect by using the code below, but for now I see no other easy way around that.

        if (!isset($cached_data['#cache_redirect'])) {
          $cached_response = $cached_data['#response'];
πŸ› Bug report
Status

Fixed

Version

10.1 ✨

Component
JSON APIΒ  β†’

Last updated 1 day ago

Created by

πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024