Commit 80be5979 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)
(cherry picked from commit c3ba4cff)
parent 69a509f1
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)) {
+2 −2
Original line number Diff line number Diff line
@@ -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'),
    ];
  }

+11 −11
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -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>');
Loading