View source
<?php
require_once dirname(__FILE__) . '/../../../tests/heartbeatwebtestcase.inc';
class HeartbeatCommentsTest extends HeartbeatWebTestCase {
protected $testRoles = array(
'administer content types',
'access content',
'view revisions',
'administer nodes',
'access user profiles',
'view heartbeat messages',
'configure heartbeat messages',
'view personal heartbeat activity',
'administer heartbeat comments',
'add heartbeat comment',
'delete own comments',
'delete any comment',
'post comments',
);
function getInfo() {
return array(
'name' => t('Heartbeat comments test'),
'description' => t('Test heartbeat comments'),
'group' => t('Heartbeat'),
);
}
function setUp() {
parent::setUp('token', 'rules', 'heartbeat', 'hrules', 'heartbeat_comments');
}
function testHeartbeatComments() {
$this
->drupalLogin($this
->drupalCreateUser($this->testRoles));
variable_set('comment_page', 2);
$edit = array(
'page_items_max' => 5,
'page_pager_ajax' => FALSE,
);
$this
->configureStream('publicheartbeat', $edit);
drupal_flush_all_caches();
$this
->drupalGet('admin/content/node-type/page');
$page_node = $this
->drupalCreateNode(array(
'type' => 'page',
'title' => 'MyFirstPage',
));
$this
->drupalGet('heartbeat/publicheartbeat');
$this
->assertText('MyFirstPage', t('The page title is displayed in the public heartbeat stream.'), t('Heartbeat'));
$edit = array(
'type' => 'single',
'attachments[heartbeat_comments]' => TRUE,
'attachments[comment_comments]' => TRUE,
);
$this
->drupalPost('admin/build/heartbeat/edit/2', $edit, t('Save'));
$this
->drupalGet('admin/build/heartbeat/edit/2');
$page_node = $this
->drupalCreateNode(array(
'type' => 'page',
'title' => 'MySecondPageWithComments',
));
$this
->drupalGet('heartbeat/publicheartbeat');
$this
->assertText('MySecondPageWithComments', t('The page title is displayed in the public heartbeat stream.'), t('Heartbeat'));
$this
->assertText('React', t('The react button is on the screen.'), t('Heartbeat'));
$edit = array(
'message' => 'My First Comment',
'nid' => 2,
'node_comment' => TRUE,
'uaid' => 2,
);
$this
->drupalPost('heartbeat/publicheartbeat', $edit, t('Submit'));
$this
->drupalGet('heartbeat/publicheartbeat');
$this
->assertText('My First Comment', t('The posted comment is displayed.'), t('Heartbeat'));
$this
->drupalGet('admin/content/heartbeat/comments');
$this
->assertText('No comments available', t('No comments found.'), t('Heartbeat'));
$edit = array(
'attachments[heartbeat_comments]' => TRUE,
'attachments[comment_comments]' => FALSE,
);
$this
->drupalPost('admin/build/heartbeat/edit/2', $edit, t('Save'));
$edit = array(
'message' => 'My First Heartbeat Comment',
'uaid' => 2,
);
$this
->drupalPost('heartbeat/publicheartbeat', $edit, t('Submit'));
$this
->drupalGet('admin/content/heartbeat/comments');
$this
->assertNoText('No comments available', t('Comments are found.'), t('Heartbeat'));
$this
->assertText('My First Heartbeat Comment', t('The posted comment can be managed.'), t('Heartbeat'));
}
}