You are here

public function MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 58
Contains \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest.

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) {
    $self
      ->assertTrue(!empty($build['#cache']));
  });
  $url = new Url('test_1', [], $options);
  $url
    ->setUrlGenerator($this->generator);
  $url
    ->toString($collect_bubbleable_metadata);
}