View source
<?php
class TalkTests extends DrupalWebTestCase {
protected $talkType = '';
protected $talkTitle = '';
public static function getInfo() {
return array(
'name' => t('Basic talk tests'),
'description' => t('Some basic tests for the talk module, including going to the talk page and making sure the comment shows up.'),
'group' => t('Talk'),
);
}
function setUp() {
parent::setUp('comment', 'talk');
$node_type = $this
->drupalCreateContentType();
$this->talkType = $node_type->type;
variable_set('comment_talk_' . $node_type->type, TRUE);
variable_set('comment_preview_' . $node_type->type, DRUPAL_OPTIONAL);
$this->talkTitle = $this
->randomName();
variable_set('talk_page', $this->talkTitle);
$this->talkLink = $this
->randomName();
variable_set('talk_link', $this->talkLink);
$this->talkTab = $this
->randomName();
variable_set('talk_tab', $this->talkTab);
$permissions = array(
'access content',
'access comments',
'post comments',
'skip comment approval',
);
$user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($user);
}
function testTalkCommentAppears() {
$settings = array();
$settings['type'] = $this->talkType;
$node = $this
->drupalCreateNode($settings);
$this
->drupalGet('node/' . $node->nid);
$this
->clickLink(t('Add new 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'));
$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),
)));
$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),
)));
}
}