You are here

protected function NodeRevisionsTest::renderContextualLinks in Drupal 10

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

Gets server-rendered contextual links for the given contextual links IDs.

Parameters

string[] $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

string The decoded JSON response body.

File

core/modules/node/tests/src/Functional/NodeRevisionsTest.php, line 375

Class

NodeRevisionsTest
Create a node with revisions and test viewing, saving, reverting, and deleting revisions for users with access for this content type.

Namespace

Drupal\Tests\node\Functional

Code

protected function renderContextualLinks(array $ids, $current_path) {
  $post = [];
  for ($i = 0; $i < count($ids); $i++) {
    $post['ids[' . $i . ']'] = $ids[$i];
  }
  $response = $this
    ->drupalPost('contextual/render', 'application/json', $post, [
    'query' => [
      'destination' => $current_path,
    ],
  ]);
  return Json::decode($response);
}