protected function AssertContentTrait::assertTitle in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/AssertContentTrait.php \Drupal\simpletest\AssertContentTrait::assertTitle()
Pass if the page title is the given string.
Parameters
string $title: The string the title should be.
string $message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Utility\SafeMarkup::format() 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 on pass, FALSE on fail.
46 calls to AssertContentTrait::assertTitle()
- AreaTitleWebTest::testTitleText in core/
modules/ views/ src/ Tests/ Handler/ AreaTitleWebTest.php - Tests the title area handler.
- 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.
- BlockContentTypeTest::testBlockContentTypeEditing in core/
modules/ block_content/ src/ Tests/ BlockContentTypeTest.php - Tests editing a block type using the UI.
- BlockTest::testBlockThemeSelector in core/
modules/ block/ src/ Tests/ BlockTest.php - Tests that the block form has a theme selector when not passed via the URL.
File
- core/
modules/ simpletest/ src/ AssertContentTrait.php, line 804 - Contains \Drupal\simpletest\AssertContentTrait.
Class
- AssertContentTrait
- Provides test methods to assert content.
Namespace
Drupal\simpletestCode
protected function assertTitle($title, $message = '', $group = 'Other') {
// Don't use xpath as it messes with HTML escaping.
preg_match('@<title>(.*)</title>@', $this
->getRawContent(), $matches);
if (isset($matches[1])) {
$actual = $matches[1];
$actual = $this
->castSafeStrings($actual);
$title = $this
->castSafeStrings($title);
if (!$message) {
$message = SafeMarkup::format('Page title @actual is equal to @expected.', array(
'@actual' => var_export($actual, TRUE),
'@expected' => var_export($title, TRUE),
));
}
return $this
->assertEqual($actual, $title, $message, $group);
}
return $this
->fail('No title element found on the page.');
}