function WebTestBase::drupalGetNodeByTitle in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::drupalGetNodeByTitle()
Get a node from the database based on its title.
Parameters
string|\Drupal\Component\Render\MarkupInterface $title: A node title, usually generated by $this->randomMachineName().
$reset: (optional) Whether to reset the entity cache.
Return value
\Drupal\node\NodeInterface A node entity matching $title.
35 calls to WebTestBase::drupalGetNodeByTitle()
- BookTest::createBookNode in core/
modules/ book/ src/ Tests/ BookTest.php - Creates a book node.
- CommentLanguageTest::testCommentLanguage in core/
modules/ comment/ src/ Tests/ CommentLanguageTest.php - Test that comment language is properly set.
- ContentTranslationContextualLinksTest::testContentTranslationContextualLinks in core/
modules/ content_translation/ src/ Tests/ ContentTranslationContextualLinksTest.php - Tests that a contextual link is available for translating a node.
- DbLogTest::doNode in core/
modules/ dblog/ src/ Tests/ DbLogTest.php - Generates and then verifies some node events.
- EntityTranslationFormTest::testEntityFormLanguage in core/
modules/ system/ src/ Tests/ Entity/ EntityTranslationFormTest.php - Tests entity form language.
File
- core/
modules/ simpletest/ src/ WebTestBase.php, line 244 - Contains \Drupal\simpletest\WebTestBase.
Class
- WebTestBase
- Test case for typical Drupal tests.
Namespace
Drupal\simpletestCode
function drupalGetNodeByTitle($title, $reset = FALSE) {
if ($reset) {
\Drupal::entityManager()
->getStorage('node')
->resetCache();
}
// Cast MarkupInterface objects to string.
$title = (string) $title;
$nodes = entity_load_multiple_by_properties('node', array(
'title' => $title,
));
// Load the first node returned from the database.
$returned_node = reset($nodes);
return $returned_node;
}