function WorkbenchModerationViewUnpublishedTestCase::testViewUnpublished in Workbench Moderation 7.3
File
- tests/
workbench_moderation.perms.test, line 49 - Permissions-related tests for workbench_moderation.module.
Class
Code
function testViewUnpublished() {
$is_moderated = workbench_moderation_node_type_moderated($this->content_type);
$this
->assertTrue($is_moderated, t('The content type is moderated.'));
// Create a new node and make sure it is unpublished.
$body_name = 'body[' . LANGUAGE_NONE . '][0]';
$edit = array(
'title' => $this
->randomName(),
"{$body_name}[value]" => $this
->randomString(128),
"{$body_name}[format]" => filter_default_format(),
);
$this
->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));
// Get the new node.
$node = $this
->drupalGetNodeByTitle($edit['title']);
$this
->assertFalse($node->status, t('New node is unpublished'));
$this
->assertTrue(isset($node->workbench_moderation), t('Workbench moderation information is present on the node object'));
$this
->assertFalse(isset($node->workbench_moderation['published']), t('Workbench moderation has no published revision'));
$this
->assertEqual($node->uid, $this->author_user->uid, 'This node was authored by the author user.');
$this
->verbose(print_r($this->loggedInUser, TRUE));
$this
->drupalLogin($this->editor_user);
global $user;
$user = user_load($this->loggedInUser->uid);
$this
->drupalGet($node->path['source']);
$this
->assertFalse($node->status, t('This node is unpublished.'));
$this
->assertResponse(200);
$this
->assertFalse($node->uid == $this->loggedInUser->uid, t('The current user is not the author of this node.'));
$this
->assertEqual($user->uid, $this->loggedInUser->uid, 'The current global user is the same as the logged in user.');
$this
->assertEqual($user->uid, $this->editor_user->uid, 'The current user is the editor user.');
$this
->assertTrue(user_access('view all unpublished content'), 'Current user has permission to view all unpublished content');
}