You are here

function NodeCreationTestCase::testUnpublishedNodeCreation in Drupal 7

Create an unpublished node and confirm correct redirect behavior.

File

modules/node/node.test, line 676
Tests for node.module.

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.'));
}