function ShoutboxDeleteTestCase::testShoutboxDeleteForm in Shoutbox 7
Same name and namespace in other branches
- 7.2 shoutbox.test \ShoutboxDeleteTestCase::testShoutboxDeleteForm()
Test that we can delete a shout.
File
- ./
shoutbox.test, line 300 - Shoutbox testing.
Class
Code
function testShoutboxDeleteForm() {
$this
->drupalGet('');
// Make sure form is available.
$this
->assertFieldById('edit-message', '', '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.');
// Now lets try to delete it.
// Get id from database.
$id = $this
->getShoutId($message, $this->sb_delete_user->uid);
$href = 'shout/' . $id . '/delete';
// The link should exist.
$this
->assertLinkByHref($href, 0, 'Delete link should exist');
$urls = $this
->xpath('//div[@id=\'shoutbox-body\']/table/tbody//a[contains(@href, :href)]', array(
':href' => $href,
));
$url_target = $this
->getAbsoluteUrl($urls[0]['href']);
$this
->drupalGet($url_target);
$this
->assertResponse(200, t('User can click delete shout link.'));
$this
->assertText(t('Are you sure you want to delete this shout?'), 'Confirmation text should exist on page');
$this
->assertText(t('This action cannot be undone.'), 'Cannot be undone text should exist on page');
$this
->assertLink('Cancel', 0, 'Cancel link exists on page.');
$this
->assertFieldById('edit-submit', NULL, 'The submit button exists on the page');
$this
->drupalPost(NULL, array(), t('Confirm'));
$this
->assertNoText($message, 'Old shout should not appear in block.');
$this
->assertText(t('There are currently no shouts'), 'There should be no shouts');
}