function AssertContentTrait::assertNoLink
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::assertNoLink()
- 10 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: use \Drupal\Component\Render\FormattableMarkup to embed variables in the message text, not t(). If left blank, a default message will be displayed.
string $group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Other'; most tests do not override this default.
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 326
Class
- AssertContentTrait
- Provides test methods to assert content.
Namespace
Drupal\KernelTestsCode
protected function assertNoLink($label, $message = '', $group = 'Other') {
// 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.