You are here

function TalkTests::testTalkCommentAppears in Talk 7

Same name and namespace in other branches
  1. 6 talk.test \TalkTests::testTalkCommentAppears()

Post a comment in our talk node type and make sure it shows up on the talk page.

File

./talk.test, line 49

Class

TalkTests

Code

function testTalkCommentAppears() {

  // Create a node to test with.
  $settings = array();
  $settings['type'] = $this->talkType;
  $node = $this
    ->drupalCreateNode($settings);

  // Navigate to the node page.
  $this
    ->drupalGet('node/' . $node->nid);

  // Click the link provided by the talk module.
  $this
    ->clickLink(t('Add new comment'));

  // Now, post a comment.
  $edit = array();
  $subject = $this
    ->randomName();
  $comment = $this
    ->randomName(30);
  $edit['subject'] = $subject;
  $edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = $comment;
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Make the actual assertions here.
  $this
    ->assertText($subject, t('Make sure that the subject of the comment appears'));
  $this
    ->assertText($comment, t('Make sure the body of the comment appears'));
  $this
    ->assertText($this->talkTitle, t('Make sure the talk title appears @title', array(
    '@title' => str_replace('[node_comment_count]', 1, $this->talkTitle),
  )));

  // Confirm that the link and tab are as they should be.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertText($this->talkLink, t('Make sure the talk link appears @title', array(
    '@title' => str_replace('[unread_comment_count]', 0, $this->talkLink),
  )));
  $this
    ->assertText($this->talkTab, t('Make sure the talk tab appears @title', array(
    '@title' => str_replace('[unread_comment_count]', 0, $this->talkTab),
  )));
}