function ShoutboxEditTestCase::testShoutboxCannotEditForm in Shoutbox 7
Same name and namespace in other branches
- 7.2 shoutbox.test \ShoutboxEditTestCase::testShoutboxCannotEditForm()
Test that user without edit permissions cannot edit.
File
- ./
shoutbox.test, line 247 - Shoutbox testing.
Class
Code
function testShoutboxCannotEditForm() {
$this
->drupalGet('');
// Make sure form is available.
$this
->assertFieldById('edit-message', '', t('The edit-messsage exists on the page'));
$message = $this
->randomName(32) . ' ' . $this
->randomName(5);
$edit = array();
$edit['message'] = $message;
$this
->drupalPost(NULL, $edit, t('Shout'));
// Make sure shout appears on page.
$this
->drupalGet('');
$this
->assertText($message, 'Shout appears in block.');
$id = $this
->getShoutId($message, $this->sb_edit_user->uid);
$this
->drupalLogout();
$this
->drupalLogin($this->sb_non_user);
$this
->assertNoFieldById('edit-message', '', 'The edit-messsage exists on the page');
$this
->assertNoText(t('Shoutbox'), 'Shoutbox appears in block.');
$this
->assertNoText(t('There are currently no shouts'), 'There should be no shouts');
// Now lets try to edit it.
// Get id from database.
$href = 'shout/' . $id . '/edit';
// The link should exist.
$this
->assertNoLinkByHref($href, 0, 'Edit link should exist');
$this
->drupalGet($href);
$this
->assertResponse(403, t('User can edit shout without permission'));
$this
->assertNoText(t('Author'));
}