$this->
assertSame(400,
$response->
getStatusCode());
$this->
assertStringContainsString('No contextual ids specified.',
(string) $response->
getBody());
$response =
$this->
renderContextualLinks($ids, 'node'
);
$this->
assertSame(200,
$response->
getStatusCode());
$json = Json::
decode((string) $response->
getBody());
$this->
assertSame('<ul class="contextual-links"><li><a href="' .
base_path() . 'node/1/edit">Edit</a></li></ul>',
$json[$ids[0
]]);
$this->
assertSame('',
$json[$ids[1
]]);
$this->
assertSame('<ul class="contextual-links"><li><a href="' .
base_path() . 'node/3/edit">Edit</a></li></ul>',
$json[$ids[2
]]);
$this->
assertSame('',
$json[$ids[3
]]);
// Verify that link language is properly handled.
$node3->
addTranslation('it'
)->
set('title',
$this->
randomString())->
save();
$id = 'node:node=' .
$node3->
id() . ':changed=' .
$node3->
getChangedTime() . '&langcode=it';
$this->
drupalGet('node',
['language' => ConfigurableLanguage::
createFromLangcode('it'
)]);
$this->
assertContextualLinkPlaceHolder($id);
// Authenticated user: can access contextual links, cannot edit articles.
$this->
drupalLogin($this->authenticatedUser
);
$this->
drupalGet('node'
);
for ($i = 0;
$i <
count($ids);
$i++
) { $this->
assertContextualLinkPlaceHolder($ids[$i]);
} $response =
$this->
renderContextualLinks([], 'node'
);