You are here

public function RouteProcessorCsrfTest::testProcessOutboundDynamicTwo in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php \Drupal\Tests\Core\Access\RouteProcessorCsrfTest::testProcessOutboundDynamicTwo()
  2. 9 core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php \Drupal\Tests\Core\Access\RouteProcessorCsrfTest::testProcessOutboundDynamicTwo()

Tests the processOutbound() method with two parameter replacements.

File

core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php, line 102

Class

RouteProcessorCsrfTest
@coversDefaultClass \Drupal\Core\Access\RouteProcessorCsrf @group Access

Namespace

Drupal\Tests\Core\Access

Code

public function testProcessOutboundDynamicTwo() {
  $route = new Route('{slug_1}/test-path/{slug_2}', [], [
    '_csrf_token' => 'TRUE',
  ]);
  $parameters = [
    'slug_1' => 100,
    'slug_2' => 'test',
  ];
  $bubbleable_metadata = new BubbleableMetadata();
  $this->processor
    ->processOutbound('test', $route, $parameters, $bubbleable_metadata);

  // Bubbleable metadata of routes with a _csrf_token route requirement is a
  // placeholder.
  $path = '100/test-path/test';
  $placeholder = Crypt::hashBase64($path);
  $placeholder_render_array = [
    '#lazy_builder' => [
      'route_processor_csrf:renderPlaceholderCsrfToken',
      [
        $path,
      ],
    ],
  ];
  $this
    ->assertEquals((new BubbleableMetadata())
    ->setAttachments([
    'placeholders' => [
      $placeholder => $placeholder_render_array,
    ],
  ]), $bubbleable_metadata);
}