You are here

public function StateFlowWebTestCase::testUnpublish in State Machine 7.3

Test just the unpublish event, verify access/non-access of anonymous users.

File

modules/state_flow/tests/state_flow.test, line 614
state_flow.test

Class

StateFlowWebTestCase
Unit tests for the StateFlow revision state machine.

Code

public function testUnpublish() {
  $edit = array();
  $edit['title'] = $this
    ->randomName(8);
  $edit['event'] = 'publish';
  $edit['event_comment'] = $this
    ->randomName(8);
  $this
    ->drupalPost("node/add/article", $edit, t('Save'));
  $this
    ->drupalGet('node/1');

  // Log out. Verify the node is publicly accessible.
  $this
    ->drupalLogout();
  $this
    ->drupalGet("node/1");
  $this
    ->assertResponse(200, 'The node is publicly accessible.');

  // Log back in and unpublish.
  $this
    ->stateFlowLoginAdmin();
  $edit = array();
  $edit['event'] = 'unpublish';
  $edit['event_comment'] = $this
    ->randomName(8);
  $edit['title'] = $this
    ->randomName(8);
  $this
    ->drupalPost('node/1/edit', $edit, t('Save'));

  // Log out. Verify the node is not publicly accessible.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('node/1');
  $this
    ->assertResponse(403, 'The node is not publicly accessible.');

  // Log in and publish from the Views tab. Send back to draft first.
  $this
    ->stateFlowLoginAdmin();
  $edit = array();
  $edit['event'] = 'to draft';
  $edit['event_comment'] = $this
    ->randomName(8);
  $this
    ->drupalPost("node/1/revisions-state-flow-states", $edit, t('Update State'));
  $edit = array();
  $edit['event'] = 'publish';
  $edit['event_comment'] = $this
    ->randomName(8);
  $this
    ->drupalPost("node/1/revisions-state-flow-states", $edit, t('Update State'));

  // Make a forward revision draft.
  $edit = array();
  $edit['event'] = 'to draft';
  $edit['event_comment'] = $this
    ->randomName(8);
  $this
    ->drupalPost('node/1/edit', $edit, t('Save'));

  // Unpublish from the Views tab.
  $edit = array();
  $edit['event'] = 'unpublish';
  $edit['event_comment'] = $this
    ->randomName(8);
  $this
    ->drupalPost("node/1/revisions-state-flow-states", $edit, t('Update State'));

  // Log out. Verify the node is not publicly accessible.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('node/1');
  $this
    ->assertResponse(403, 'The node is not publicly accessible.');
}