class UrlBubbleableMetadataBubblingTest

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php \Drupal\Tests\system\Functional\Render\UrlBubbleableMetadataBubblingTest
  2. 10 core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php \Drupal\Tests\system\Functional\Render\UrlBubbleableMetadataBubblingTest
  3. 8.9.x core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php \Drupal\Tests\system\Functional\Render\UrlBubbleableMetadataBubblingTest

Tests that URL bubbleable metadata is correctly bubbled.

@group Render

Hierarchy

Expanded class hierarchy of UrlBubbleableMetadataBubblingTest

File

core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php, line 14

Namespace

Drupal\Tests\system\Functional\Render
View source
class UrlBubbleableMetadataBubblingTest extends BrowserTestBase {
  use AssertPageCacheContextsAndTagsTrait;
  
  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'cache_test',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
  }
  
  /**
   * Tests that URL bubbleable metadata is correctly bubbled.
   */
  public function testUrlBubbleableMetadataBubbling() {
    // Test that regular URLs bubble up bubbleable metadata when converted to
    // string.
    $url = Url::fromRoute('cache_test.url_bubbling');
    $this->drupalGet($url);
    $this->assertCacheContext('url.site');
    $this->assertSession()
      ->responseContains($url->setAbsolute()
      ->toString());
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.