function NodeCreationTestCase::testNodeCreation
7.x node.test | NodeCreationTestCase::testNodeCreation() |
Creates a "Basic page" node and verifies its consistency in the database.
File
- drupal-7.x/
modules/ node/ node.test, line 544 - 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->drupalPost('node/add/page', $edit, t('Save'));
// Check that the Basic page has been created.
$this->assertRaw(t('!post %title has been created.', array('!post' => 'Basic page', '%title' => $edit["title"])), 'Basic page created.');
// Check that the node exists in the database.
$node = $this->drupalGetNodeByTitle($edit["title"]);
$this->assertTrue($node, 'Node found in database.');
}