1.20.x node.test NodeCreationTestCase::testUnpublishedNodeCreation()

Create an unpublished node and confirm correct redirect behavior.

File

modules/node/tests/node.test, line 974
Tests for node.module.

Class

NodeCreationTestCase
Tests creating and saving a node.

Code

function testUnpublishedNodeCreation() {
  // Set "Page" content type to be unpublished by default.
  $node_type = node_type_get_type('page');
  $node_type->settings['status_default'] = 0;
  node_type_save($node_type);

  // Set the front page to the default "node" page.
  config_set('system.core', 'site_frontpage', 'node');

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

  // Check that the user was redirected to the home page.
  $this->assertText(t('This is your first post! You may edit or delete it.'), 'The user is redirected to the home page.');
}