You are here

function ShoutboxEditTestCase::testShoutboxEditForm in Shoutbox 7

Same name and namespace in other branches
  1. 7.2 shoutbox.test \ShoutboxEditTestCase::testShoutboxEditForm()

Test that we can get an edit form.

File

./shoutbox.test, line 209
Shoutbox testing.

Class

ShoutboxEditTestCase

Code

function testShoutboxEditForm() {
  $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 edit it.
  // Get id from database.
  $id = $this
    ->getShoutId($message, $this->sb_edit_user->uid);
  $href = 'shout/' . $id . '/edit';

  // The link should exist.
  $this
    ->assertLinkByHref($href, 0, 'Edit link should exist');
  $this
    ->drupalGet($href);
  $this
    ->assertText('Author');
  $href = 'user/' . $this->sb_edit_user->uid;
  $this
    ->assertLinkByHref($href, 0, 'User link should exist');
  $this
    ->assertText('Changed');
  $this
    ->assertText('Shout');
  $this
    ->assertFieldById('edit-shout', $message, 'The edit-shout filed exists on the page');
  $new_message = $this
    ->randomName(10) . ' ' . $this
    ->randomName(20);
  $edit = array();
  $edit['shout'] = $new_message;
  $this
    ->drupalPost(NULL, $edit, t('Update'));
  $this
    ->assertText(t('Your shout has been saved.'), 'Saved message appears on page.');
  $this
    ->drupalGet('');
  $this
    ->assertText($new_message, 'Shout appears in block.');
  $this
    ->assertNoText($message, 'Old shout should not appear in block.');
}