protected function AssertContentTrait::assertLink in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/AssertContentTrait.php \Drupal\simpletest\AssertContentTrait::assertLink()
Passes if a link with the specified label is found.
An optional link index may be passed.
Parameters
string|\Drupal\Component\Render\MarkupInterface $label: Text between the anchor tags.
int $index: Link position counting from zero.
string $message: (optional) A message to display with the assertion. Do not translate messages: use strtr() 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, FALSE otherwise.
88 calls to AssertContentTrait::assertLink()
- AdminTest::testAdminPages in core/
modules/ system/ src/ Tests/ System/ AdminTest.php - Tests output on administrative listing pages.
- AnalyzeTest::testAnalyzeBasic in core/
modules/ views_ui/ src/ Tests/ AnalyzeTest.php - Tests that analyze works in general.
- BlockContentListTest::testListing in core/
modules/ block_content/ src/ Tests/ BlockContentListTest.php - Tests the custom block listing page.
- BlockContentListViewsTest::testListing in core/
modules/ block_content/ src/ Tests/ BlockContentListViewsTest.php - Tests the custom block listing page.
- BlockUiTest::testBlockAdminUiPage in core/
modules/ block/ src/ Tests/ BlockUiTest.php - Test block admin page exists and functions correctly.
File
- core/
modules/ simpletest/ src/ AssertContentTrait.php, line 305 - Contains \Drupal\simpletest\AssertContentTrait.
Class
- AssertContentTrait
- Provides test methods to assert content.
Namespace
Drupal\simpletestCode
protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {
// Cast MarkupInterface objects to string.
$label = (string) $label;
$links = $this
->xpath('//a[normalize-space(text())=:label]', array(
':label' => $label,
));
$message = $message ? $message : strtr('Link with label %label found.', array(
'%label' => $label,
));
return $this
->assert(isset($links[$index]), $message, $group);
}