You are here

function WorkbenchModerationTransitionTestCase::testUnpublishTransition in Workbench Moderation 7.3

File

tests/workbench_moderation.transition.test, line 129
Tests for node transition hooks with workbench_moderation.module.

Class

WorkbenchModerationTransitionTestCase
@file Tests for node transition hooks with workbench_moderation.module.

Code

function testUnpublishTransition() {

  // Create a new node and publish it immediately. Assumes that
  // WorkbenchModerationPublishFromNodeFormTestCase passes.
  $body_name = 'body[' . LANGUAGE_NONE . '][0]';
  $edit = array(
    'title' => $this
      ->randomName(),
    "{$body_name}[value]" => $this
      ->randomString(128),
    "{$body_name}[format]" => filter_default_format(),
    'workbench_moderation_state_new' => workbench_moderation_state_published(),
  );
  $this
    ->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));
  $node = $this
    ->drupalGetNodeByTitle($edit['title']);
  $expected = array(
    'nid' => 1,
    'vid' => 1,
    'title' => $edit['title'],
    'previous_state' => 'draft',
    'new_state' => 'published',
    'status' => 1,
  );
  $this
    ->assertTransition($expected);

  // Unpublish the node via the unpublish confirmation form.
  $this
    ->drupalPost("node/{$node->nid}/moderation/{$node->vid}/unpublish", array(), t('Unpublish'));
  $expected = array(
    'nid' => 1,
    'vid' => 1,
    'title' => $edit['title'],
    'previous_state' => 'published',
    'new_state' => 'draft',
    'status' => 0,
  );
  $this
    ->assertTransition($expected);
}