function WebTestBase::drupalGetNodeByTitle

Get a node from the database based on its title.

Parameters

$title: A node title, usually generated by $this->randomName().

$reset: (optional) Whether to reset the entity cache.

Return value

A node entity matching $title.

37 calls to WebTestBase::drupalGetNodeByTitle()
BookTest::createBookNode in drupal/core/modules/book/lib/Drupal/book/Tests/BookTest.php
Create book node.
CommentLanguageTest::testCommentLanguage in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
Test that comment language is properly set.
DBLogTest::doNode in drupal/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php
Generates and then verifies some node events.
EntityTranslationFormTest::testEntityFormLanguage in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
Tests entity form language.
FileFieldWidgetTest::testPrivateFileComment in drupal/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
Tests that download restrictions on private files work on comments.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 176
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

function drupalGetNodeByTitle($title, $reset = FALSE) {
  if ($reset) {
    entity_get_controller('node')
      ->resetCache();
  }
  $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;
}