Commit 56c825fc authored by catch's avatar catch
Browse files

Issue #2254209 by smustgrave, marvil07, quietone, sun, catch, Wim Leers: Fix...

Issue #2254209 by smustgrave, marvil07, quietone, sun, catch, Wim Leers: Fix test performance of Drupal\system\Tests\Cache\PageCacheTagsIntegrationTest

(cherry picked from commit 57ca853a)
parent 47299605
Loading
Loading
Loading
Loading
Loading
+53 −2
Original line number Diff line number Diff line
@@ -2,11 +2,18 @@

namespace Drupal\Tests\page_cache\Functional;

use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Core\Language\LanguageInterface;
use Drupal\filter\Entity\FilterFormat;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
use Drupal\node\NodeInterface;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
use Symfony\Component\Yaml\Yaml;

/**
 * Enables the page cache and tests its cache tags in various scenarios.
@@ -17,11 +24,29 @@
class PageCacheTagsIntegrationTest extends BrowserTestBase {

  use AssertPageCacheContextsAndTagsTrait;
  use CommentTestTrait;

  /**
   * {@inheritdoc}
   */
  protected $profile = 'standard';
  protected $defaultTheme = 'olivero';

  /**
   * Modules to enable.
   * @var array
   */
  protected static $modules = [
    'big_pipe',
    'block',
    'comment',
    'editor',
    'filter',
    'language',
    'help',
    'node',
    'search',
    'views',
  ];

  /**
   * {@inheritdoc}
@@ -36,6 +61,32 @@ protected function setUp(): void {
   * Tests that cache tags are properly bubbled up to the page level.
   */
  public function testPageCacheTags() {
    $config = $this->config('language.types');
    $config->set('configurable', [LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT]);
    $config->set('negotiation.language_content.enabled', [
      LanguageNegotiationUrl::METHOD_ID => 0,
      LanguageNegotiationContentEntity::METHOD_ID => 1,
    ]);
    $config->save();

    // Create two filters.
    FilterFormat::create(
      Yaml::parseFile('core/profiles/standard/config/install/filter.format.basic_html.yml')
    )->save();
    FilterFormat::create(
      Yaml::parseFile('core/profiles/standard/config/install/filter.format.full_html.yml')
    )->save();

    $this->drupalCreateContentType(['type' => 'page', 'title' => 'Basic page']);
    $this->addDefaultCommentField('node', 'page');

    // To generate search and comment tags.
    $anonymous = Role::load(RoleInterface::ANONYMOUS_ID);
    $anonymous
      ->grantPermission('search content')
      ->grantPermission('access comments');
    $anonymous->save();

    // Create two nodes.
    $author_1 = $this->drupalCreateUser();
    $node_1 = $this->drupalCreateNode([
@@ -80,7 +131,7 @@ public function testPageCacheTags() {
      'cookies:big_pipe_nojs',
      'session.exists',
      'user.permissions',
      'user.roles:authenticated',
      'user.roles',
    ];

    // Full node page 1.