function AssertContentTrait::assertNoLink
Same name in other branches
- 9 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::assertNoLink()
- 8.9.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::assertNoLink()
- 11.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::assertNoLink()
Passes if a link with the specified label is not found.
Parameters
string|\Drupal\Component\Render\MarkupInterface $label: Text between the anchor tags.
string $message: (optional) A message to display with the assertion. Do not translate messages with t(). Use double quotes and embed variables directly in message text, or use sprintf() if necessary. Avoid the use of \Drupal\Component\Render\FormattableMarkup unless you cast the object to a string. If left blank, a default message will be displayed.
Return value
bool TRUE if the assertion succeeded.
1 call to AssertContentTrait::assertNoLink()
- CommentUserNameTest::testUsername in core/
modules/ comment/ tests/ src/ Kernel/ Views/ CommentUserNameTest.php - Tests the username formatter.
File
-
core/
tests/ Drupal/ KernelTests/ AssertContentTrait.php, line 305
Class
- AssertContentTrait
- Provides test methods to assert content.
Namespace
Drupal\KernelTestsCode
protected function assertNoLink($label, $message = '') {
// Cast MarkupInterface objects to string.
$label = (string) $label;
$links = $this->xpath('//a[normalize-space(text())=:label]', [
':label' => $label,
]);
$message = $message ? $message : new FormattableMarkup('Link with label %label not found.', [
'%label' => $label,
]);
$this->assertEmpty($links, $message);
return TRUE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.