You are here

public function StateFlowWebTestCase::testMoveToDraftAndEditDraft in State Machine 7.3

Verify that moving from published to draft and editing the draft a second time still leaves the published revision accessible.

File

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

Class

StateFlowWebTestCase
Unit tests for the StateFlow revision state machine.

Code

public function testMoveToDraftAndEditDraft() {

  // Create new draft node
  debug('Make node 1, vid: 1');
  $edit = array();
  $title = $this
    ->randomName(8);
  $edit['title'] = $title;
  $edit['event'] = 'publish';
  $edit['event_comment'] = $this
    ->randomName(8);
  $this
    ->drupalPost("node/add/article", $edit, t('Save'));

  // Then make another revision of the first node.
  debug('Create new revision for node 1, vid: 2 and drafty forward revision vid: 3');
  $edit = array();
  $new_title = $this
    ->randomName(8);
  $edit['title'] = $new_title;
  $edit['event'] = 'to draft';
  $edit['event_comment'] = $this
    ->randomName(8);
  $edit['revision'] = 1;
  $this
    ->drupalPost("node/1/edit", $edit, t('Save'));

  // Edit the draft and save it.
  debug('Save draft revision vid: 2 and drafty forward revision vid: 4');
  $edit = array();
  $new_title = $this
    ->randomName(8);
  $edit['title'] = $new_title;
  $edit['event'] = 'keep in draft';
  $edit['event_comment'] = $this
    ->randomName(8);
  $this
    ->drupalPost("node/1/edit", $edit, t('Save'));

  // Now test that the node is accessible
  $this
    ->drupalLogout();
  $this
    ->drupalGet("node/1");
  $this
    ->assertText($title, t('After editing the draft for a second time, anonymous user can see node title.'));
}