UrlBubbleableMetadataBubblingTest.php

Same filename in other branches
  1. 9 core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php
  2. 8.9.x core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php
  3. 11.x core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php

Namespace

Drupal\Tests\system\Functional\Render

File

core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\system\Functional\Render;

use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;

/**
 * Tests that URL bubbleable metadata is correctly bubbled.
 *
 * @group Render
 */
class UrlBubbleableMetadataBubblingTest extends BrowserTestBase {
    use AssertPageCacheContextsAndTagsTrait;
    
    /**
     * {@inheritdoc}
     */
    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() : void {
        // 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());
    }

}

Classes

Title Deprecated Summary
UrlBubbleableMetadataBubblingTest Tests that URL bubbleable metadata is correctly bubbled.

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