You are here

protected function ContextualDynamicContextTest::renderContextualLinks in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php \Drupal\Tests\contextual\Functional\ContextualDynamicContextTest::renderContextualLinks()
  2. 9 core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php \Drupal\Tests\contextual\Functional\ContextualDynamicContextTest::renderContextualLinks()

Get server-rendered contextual links for the given contextual link ids.

Parameters

array $ids: An array of contextual link ids.

string $current_path: The Drupal path for the page for which the contextual links are rendered.

Return value

\Psr\Http\Message\ResponseInterface The response object.

File

core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php, line 260

Class

ContextualDynamicContextTest
Tests if contextual links are showing on the front page depending on permissions.

Namespace

Drupal\Tests\contextual\Functional

Code

protected function renderContextualLinks($ids, $current_path) {
  $tokens = array_map([
    $this,
    'createContextualIdToken',
  ], $ids);
  $http_client = $this
    ->getHttpClient();
  $url = Url::fromRoute('contextual.render', [], [
    'query' => [
      '_format' => 'json',
      'destination' => $current_path,
    ],
  ]);
  return $http_client
    ->request('POST', $this
    ->buildUrl($url), [
    'cookies' => $this
      ->getSessionCookies(),
    'form_params' => [
      'ids' => $ids,
      'tokens' => $tokens,
    ],
    'http_errors' => FALSE,
  ]);
}