You are here

public function MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling()
  2. 9 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 53

Class

MetadataBubblingUrlGeneratorTest
Confirm that the MetadataBubblingUrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Render

Code

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