function NodeCreationTestCase::testUnpublishedNodeCreation

Create an unpublished node and confirm correct redirect behavior.

File

modules/node/node.test, line 691

Class

NodeCreationTestCase
Tests creating and saving a node.

Code

function testUnpublishedNodeCreation() {
  // Set "Basic page" content type to be unpublished by default.
  variable_set('node_options_page', array());
  // Set the front page to the default "node" page.
  variable_set('site_frontpage', 'node');
  // Create a node.
  $edit = array();
  $edit["title"] = $this->randomName(8);
  $edit["body[" . LANGUAGE_NONE . "][0][value]"] = $this->randomName(16);
  $this->drupalPost('node/add/page', $edit, t('Save'));
  // Check that the user was redirected to the home page.
  $this->assertText(t('Welcome to Drupal'), t('The user is redirected to the home page.'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.