1 node.test NodeCreationTestCase::testNodeCreation()

Creates a "Page" node and verifies its consistency in the database.

File

core/modules/node/tests/node.test, line 1105
Tests for node.module.

Class

NodeCreationTestCase
Tests creating and saving a node.

Code

function testNodeCreation() {
  // Create a node.
  $edit = array();
  $langcode = LANGUAGE_NONE;
  $edit["title"] = $this->randomName(8);
  $edit["body[$langcode][0][value]"] = $this->randomName(16);
  $this->backdropPost('node/add/page', $edit, t('Save'));

  // Check that the Page has been created.
  $this->assertRaw(t('!post %title has been created.', array('!post' => 'Page', '%title' => $edit["title"])), 'Page created.');

  // Check that the node exists in the database.
  $node = $this->backdropGetNodeByTitle($edit["title"]);
  $this->assertTrue($node, 'Node found in database.');
}