function NodeCreationTestCase::testNodeCreation
Creates a "Basic page" node and verifies its consistency in the database.
File
-
modules/
node/ node.test, line 620
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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.