function MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling()
  3. 11.x core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling()

Tests bubbling of cacheable metadata for URLs.

@covers ::bubble

@dataProvider providerUrlBubbleableMetadataBubbling

Parameters

bool $collect_bubbleable_metadata: Whether bubbleable metadata should be collected.

int $invocations: The expected amount of invocations for the ::bubble() method.

array $options: The URL options.

File

core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php, line 55

Class

MetadataBubblingUrlGeneratorTest
Confirm that the MetadataBubblingUrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Render

Code

public function testUrlBubbleableMetadataBubbling($collect_bubbleable_metadata, $invocations, array $options) : void {
    $self = $this;
    $this->renderer
        ->expects($this->exactly($invocations))
        ->method('render')
        ->willReturnCallback(function ($build) {
        $this->assertArrayHasKey('#cache', $build);
    });
    $url = new Url('test_1', [], $options);
    $url->setUrlGenerator($this->generator);
    $url->toString($collect_bubbleable_metadata);
}

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