$cached_id = 'block:block=' .
$cached_block->
id() . ':langcode=en|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1&langcode=en';
$cached_id_token = Crypt::
hmacBase64($cached_id, Settings::
getHashSalt() .
$this->container->
get('private_key'
)->
get());
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
// Check existence of the contextual link placeholders.
$this->
assertSession()->
responseContains('<div' .
new Attribute(['data-contextual-id' =>
$id, 'data-contextual-token' =>
$id_token, 'data-drupal-ajax-container' => ''
]) . '></div>'
);
$this->
assertSession()->
responseContains('<div' .
new Attribute(['data-contextual-id' =>
$cached_id, 'data-contextual-token' =>
$cached_id_token, 'data-drupal-ajax-container' => ''
]) . '></div>'
);
// Get server-rendered contextual links.
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
$post =
['ids[0]' =>
$id, 'ids[1]' =>
$cached_id, 'tokens[0]' =>
$id_token, 'tokens[1]' =>
$cached_id_token];
$url = 'contextual/render?_format=json,destination=test-page';
$this->
getSession()->
getDriver()->
getClient()->
request('POST',
$url,
$post);
$this->
assertSession()->
statusCodeEquals(200
);
$json = Json::
decode($this->
getSession()->
getPage()->
getContent());
$this->
assertSame('<ul class="contextual-links"><li><a href="' .
base_path() . 'admin/structure/block/manage/' .
$block->
id() . '">Configure block</a></li><li><a href="' .
base_path() . 'admin/structure/block/manage/' .
$block->
id() . '/delete">Remove block</a></li><li><a href="' .
base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>',
$json[$id]);
$this->
assertSame('<ul class="contextual-links"><li><a href="' .
base_path() . 'admin/structure/block/manage/' .
$cached_block->
id() . '">Configure block</a></li><li><a href="' .
base_path() . 'admin/structure/block/manage/' .
$cached_block->
id() . '/delete">Remove block</a></li><li><a href="' .
base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>',
$json[$cached_id]);
}}