'Atrium',
'description' => 'Tests for core Atrium functionality.',
'group' => 'Atrium',
);
}
/**
* Implementation of setUp().
*/
function setUp() {
parent::setUp();
$this->atriumBasic();
}
/**
* Test comment toggling.
*/
function testCommentToggle() {
$this->drupalLogin($this->atriumUsers['user']);
$node = $this->atriumCreateGroupContent($this->atriumGroups['public'], 'blog');
// Test that the comment form exists and the node owner can toggle
// form commenting on and off.
$this->drupalGet("{$this->atriumGroups['public']->path}/node/{$node->nid}");
$this->assertField('comment', t('Comment form found.'));
$this->assertField('edit-comment-toggle', t('Comment toggler form found.'));
// Admin should have access as well.
$this->drupalLogin($this->atriumUsers['administrator']);
$this->drupalGet("{$this->atriumGroups['public']->path}/node/{$node->nid}");
$this->assertField('edit-comment-toggle', t('Comment toggler form found.'));
// Manager (and other users) do not have access.
$this->drupalLogin($this->atriumUsers['manager']);
$this->drupalGet("{$this->atriumGroups['public']->path}/node/{$node->nid}");
$this->assertNoField('edit-comment-toggle', t('Comment toggler form not found.'));
// Turn off commenting.
$this->drupalLogin($this->atriumUsers['user']);
$this->drupalPost("{$this->atriumGroups['public']->path}/node/{$node->nid}", array(), t('Close comment thread'));
// Test that comments are actually off.
$this->drupalGet("{$this->atriumGroups['public']->path}/node/{$node->nid}");
$this->assertNoField('comment', t('Comment form not found.'));
$this->assertField('edit-comment-toggle', t('Comment toggler form found.'));
$this->drupalPost("{$this->atriumGroups['public']->path}/node/{$node->nid}", array(), t('Reopen comment thread'));
// Admin should be able to turn them back on.
$this->drupalLogin($this->atriumUsers['administrator']);
$this->drupalGet("{$this->atriumGroups['public']->path}/node/{$node->nid}");
$this->assertField('edit-comment-toggle', t('Comment toggler form found.'));
// Manager should not.
$this->drupalLogin($this->atriumUsers['manager']);
$this->drupalGet("{$this->atriumGroups['public']->path}/node/{$node->nid}");
$this->assertNoField('edit-comment-toggle', t('Comment toggler form not found.'));
// Create a non-comment enabled content type. Make sure toggler form
// does not appear.
$this->drupalLogin($this->atriumUsers['user']);
$book = $this->atriumCreateGroupContent($this->atriumGroups['public'], 'book');
$this->drupalGet("{$this->atriumGroups['public']->path}/node/{$book->nid}");
$this->assertNoField('edit-comment-toggle', t('Comment toggler form not found.'));
}
/**
* Ensure that 403 pages display a login form for anonymous users.
*/
function test403() {
$this->drupalLogout();
$this->drupalGet("node/{$this->atriumGroups['private']->nid}");
$this->assertText(t('Username'));
$this->assertText(t('Password'));
$user = $this->atriumCreateUser('authenticated user');
$this->drupalLogin($user);
$this->drupalGet("node/{$this->atriumGroups['private']->nid}");
$this->assertResponse(403, t('Access denied'));
}
/**
* Test archiving.
*/
function testArchive() {
$this->drupalLogin($this->atriumCreateUser('administrator'));
$group = $this->atriumCreateGroup();
$post = $this->atriumCreateGroupContent($group, 'blog');
// Archive the group.
$this->drupalPost("node/{$group->nid}/archive", array(), t('Archive'));
// Check that there is a message on both group & blog nodes.
$this->drupalGet("node/{$group->nid}");
$message = t('This !type is archived. You may not add or alter any of its content.', array('!type' => node_get_types('name', $group->type)));
$this->assertRaw($message);
$this->drupalGet("node/{$post->nid}");
$message = t('This !type is archived. You may not add or alter any of its content.', array('!type' => node_get_types('name', $group->type)));
$this->assertRaw($message);
// Check that blog node editing is disabled.
$this->drupalGet("node/{$post->nid}/edit");
$this->assertResponse(403, t('Access denied'));
// Reactivate it.
$this->drupalPost("node/{$group->nid}/reactivate", array(), t('Reactivate'));
$message = t('The @type @title has been reactivated.', array('@type' => node_get_types('name', $group->type), '@title' => $group->title));
$this->assertRaw($message);
// Check that blog node editing works.
$this->drupalGet("node/{$post->nid}/edit");
$this->assertResponse(200, t('Accessible'));
}
}