UserBlocksTest needlessly tests the caching layer

Created on 18 September 2019, over 5 years ago
Updated 13 February 2023, almost 2 years ago

UserBlocksTest::testUserLoginBlock() has some very specific testing of when DynamicPageCacheSubscriber should report a HIT or MISS. This is not the place to test that as we have special tests for DynamicPageCacheSubscriber.

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-154: 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 easy fix is to remove the header checks, although we might as well also remove the following section as it adds nothing new to the test aside from obviously trying to test DPC behavior:

    // Repeat with different query arguments.
    $this->drupalLogout();
    $this->drupalGet('filter/tips', ['query' => ['foo' => 'baz']]);
    $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER));
    $this->drupalPostForm(NULL, $edit, t('Log in'));
    $this->assertNoText(t('User login'), 'Logged in.');
    $this->assertPattern('!<title.*?' . t('Compose tips') . '.*?</title>!', 'Still on the same page after login for allowed page');
    $this->assertTrue(strpos($this->getUrl(), '/filter/tips?foo=baz') !== FALSE, 'Correct query arguments are displayed after login');
πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
User moduleΒ  β†’

Last updated 7 days ago

Created by

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

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.71.5 2024