You are here

function WorkbenchModerationPublishFromNodeFormTestCase::testPublishFromNodeForm in Workbench Moderation 7.3

Same name and namespace in other branches
  1. 7 tests/workbench_moderation.test \WorkbenchModerationPublishFromNodeFormTestCase::testPublishFromNodeForm()

File

tests/workbench_moderation.test, line 221
Tests for workbench_moderation.module.

Class

WorkbenchModerationPublishFromNodeFormTestCase

Code

function testPublishFromNodeForm() {

  // Create a new node and publish it immediately.
  $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'));

  // Get the new node and make sure it is published.
  $node = $this
    ->drupalGetNodeByTitle($edit['title']);
  $this
    ->assertTrue(isset($node->workbench_moderation['published']), t('Workbench moderation has a published revision'));
  $this
    ->assertEqual($node->vid, $node->workbench_moderation['published']->vid, t('Published revision is loaded by default'));
  $this
    ->assertTrue($node->status, t('Published revision has status = 1'));

  // Test anonymous access to the published content.
  $this
    ->drupalLogout();
  $this
    ->drupalGet("node/{$node->nid}");
  $this
    ->assertResponse(200, t('Anonymous users can access the published content'));
}