Skip to content
Snippets Groups Projects
Commit 967198ce authored by catch's avatar catch
Browse files

Issue #3477586 by spokje, catch, godotislate, berdir, dww, nicxvan: [random...

Issue #3477586 by spokje, catch, godotislate, berdir, dww, nicxvan: [random test failure] LayoutBuilderBlocksTest::testBlockPlaceholder failing

(cherry picked from commit 3df2a166)
parent d5f2b47e
Branches
Tags
No related merge requests found
Pipeline #383049 passed with warnings
Pipeline: drupal

#383074

    Pipeline: drupal

    #383067

      Pipeline: drupal

      #383052

        ......@@ -19,7 +19,7 @@ class TestCacheBlock extends BlockBase {
        * {@inheritdoc}
        */
        public function build() {
        $content = \Drupal::state()->get('block_test.content');
        $content = \Drupal::keyValue('block_test')->get('content');
        $build = [];
        if (!empty($content)) {
        ......
        ......@@ -20,8 +20,8 @@ class TestHtmlBlock extends BlockBase {
        */
        public function build() {
        return [
        '#attributes' => \Drupal::state()->get('block_test.attributes'),
        '#children' => \Drupal::state()->get('block_test.content'),
        '#attributes' => \Drupal::keyvalue('block_test')->get('attributes'),
        '#children' => \Drupal::keyValue('block_test')->get('content'),
        ];
        }
        ......
        ......@@ -85,7 +85,7 @@ public function testCachePerRole(): void {
        // Enable our test block. Set some content for it to display.
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalLogin($this->normalUser);
        $this->drupalGet('');
        $this->assertSession()->pageTextContains($current_content);
        ......@@ -93,7 +93,7 @@ public function testCachePerRole(): void {
        // Change the content, but the cached copy should still be served.
        $old_content = $current_content;
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalGet('');
        $this->assertSession()->pageTextContains($old_content);
        ......@@ -107,7 +107,7 @@ public function testCachePerRole(): void {
        // Test whether the cached data is served for the correct users.
        $old_content = $current_content;
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalLogout();
        $this->drupalGet('');
        // Anonymous user does not see content cached per-role for normal user.
        ......@@ -138,14 +138,14 @@ public function testCachePermissions(): void {
        \Drupal::state()->set('block_test.cache_contexts', []);
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalGet('');
        $this->assertSession()->pageTextContains($current_content);
        $old_content = $current_content;
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        // Block content served from cache.
        $this->drupalGet('user');
        ......@@ -164,7 +164,7 @@ public function testNoCache(): void {
        \Drupal::state()->set('block_test.cache_max_age', 0);
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        // If max_age = 0 has no effect, the next request would be cached.
        $this->drupalGet('');
        ......@@ -172,7 +172,7 @@ public function testNoCache(): void {
        // A cached copy should not be served.
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalGet('');
        // Maximum age of zero prevents blocks from being cached.
        $this->assertSession()->pageTextContains($current_content);
        ......@@ -185,7 +185,7 @@ public function testCachePerUser(): void {
        \Drupal::state()->set('block_test.cache_contexts', ['user']);
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalLogin($this->normalUser);
        $this->drupalGet('');
        ......@@ -193,7 +193,7 @@ public function testCachePerUser(): void {
        $old_content = $current_content;
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        // Block is served from per-user cache.
        $this->drupalGet('');
        ......@@ -217,14 +217,14 @@ public function testCachePerPage(): void {
        \Drupal::state()->set('block_test.cache_contexts', ['url']);
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalGet('test-page');
        $this->assertSession()->pageTextContains($current_content);
        $old_content = $current_content;
        $current_content = $this->randomMachineName();
        \Drupal::state()->set('block_test.content', $current_content);
        \Drupal::keyValue('block_test')->set('content', $current_content);
        $this->drupalGet('user');
        $this->assertSession()->statusCodeEquals(200);
        ......
        ......@@ -35,8 +35,8 @@ protected function setUp(): void {
        ]));
        // Enable the test_html block, to test HTML ID and attributes.
        \Drupal::state()->set('block_test.attributes', ['data-custom-attribute' => 'foo']);
        \Drupal::state()->set('block_test.content', $this->randomMachineName());
        \Drupal::keyValue('block_test')->set('attributes', ['data-custom-attribute' => 'foo']);
        \Drupal::keyValue('block_test')->set('content', $this->randomMachineName());
        $this->drupalPlaceBlock('test_html', ['id' => 'test_html_block']);
        // Enable a menu block, to test more complicated HTML.
        ......
        ......@@ -48,7 +48,7 @@ public function testXssInTitle(): void {
        $this->container->get('module_installer')->install(['block_test']);
        $this->drupalPlaceBlock('test_xss_title', ['label' => '<script>alert("XSS label");</script>']);
        \Drupal::state()->set('block_test.content', $this->randomMachineName());
        \Drupal::keyValue('block_test')->set('content', $this->randomMachineName());
        $this->drupalGet('');
        // Check that the block title was properly sanitized when rendered.
        $this->assertSession()->responseNotContains('<script>alert("XSS label");</script>');
        ......
        ......@@ -54,7 +54,7 @@ protected function setUp(): void {
        ->get('entity_type.manager')
        ->getStorage('block');
        \Drupal::state()->set('block_test.content', 'Llamas &gt; unicorns!');
        \Drupal::keyValue('block_test')->set('content', 'Llamas &gt; unicorns!');
        // Create a block with only required values.
        $this->block = $this->controller->create([
        ......@@ -73,7 +73,7 @@ protected function setUp(): void {
        * Tests the rendering of blocks.
        */
        public function testBasicRendering(): void {
        \Drupal::state()->set('block_test.content', '');
        \Drupal::keyValue('block_test')->set('content', '');
        $entity = $this->controller->create([
        'id' => 'test_block1',
        ......@@ -136,7 +136,7 @@ public function testBlockViewBuilderCache(): void {
        'plugin' => 'test_cache',
        ]);
        $this->block->save();
        \Drupal::state()->set('block_test.content', NULL);
        \Drupal::keyValue('block_test')->set('content', NULL);
        // Verify cache handling for an empty block.
        $this->verifyRenderCacheHandling();
        ......@@ -203,7 +203,7 @@ public function testBlockViewBuilderViewAlter(): void {
        $this->assertSame('Llamas > unicorns!', trim((string) $this->cssSelect('[foo=bar]')[0]));
        \Drupal::state()->set('block_test_view_alter_suffix', FALSE);
        \Drupal::state()->set('block_test.content', NULL);
        \Drupal::keyValue('block_test')->set('content', NULL);
        Cache::invalidateTags($this->block->getCacheTagsToInvalidate());
        // Advanced: cached block, but an alter hook adds a #pre_render callback to
        ......
        ......@@ -38,7 +38,7 @@ protected function setUp(): void {
        // @todo If our block does not contain any content then the cache context
        // is not bubbling up and the test fails. Remove this line once the cache
        // contexts are properly set. See https://www.drupal.org/node/2529980.
        \Drupal::state()->set('block_test.content', 'Needs to have some content');
        \Drupal::keyValue('block_test')->set('content', 'Needs to have some content');
        $this->drupalLogin($this->drupalCreateUser());
        }
        ......
        ......@@ -213,7 +213,7 @@ public function testBlockPlaceholder(): void {
        $assert_session->pageTextNotContains($block_content);
        // Set block content and reload the page.
        \Drupal::state()->set('block_test.content', $block_content);
        \Drupal::keyValue('block_test')->set('content', $block_content);
        $this->getSession()->reload();
        // The block placeholder is no longer displayed and the content is visible.
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment