You are here

function HeartbeatCommentsTest::testHeartbeatComments in Heartbeat 6.4

Tests if a heartbeat message is logged for an event.

File

modules/heartbeat_comments/tests/heartbeatcomments.test, line 52

Class

HeartbeatCommentsTest
Class HeartbeatRulesTest

Code

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',
  ));

  // Get a stream page and check if the page post appears in the heartbeat activity stream.
  $this
    ->drupalGet('heartbeat/publicheartbeat');
  $this
    ->assertText('MyFirstPage', t('The page title is displayed in the public heartbeat stream.'), t('Heartbeat'));

  // Configure the message type to have node comments.
  $edit = array(
    'type' => 'single',
    'attachments[heartbeat_comments]' => TRUE,
    'attachments[comment_comments]' => TRUE,
  );
  $this
    ->drupalPost('admin/build/heartbeat/edit/2', $edit, t('Save'));

  // Verbose check, not needed otherwise.
  $this
    ->drupalGet('admin/build/heartbeat/edit/2');

  // Get a stream page and check if the page post appears in the heartbeat activity stream.
  $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'));

  // Add a comment and check if it's there.
  $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'));

  // Check the comment administration.
  $this
    ->drupalGet('admin/content/heartbeat/comments');
  $this
    ->assertText('No comments available', t('No comments found.'), t('Heartbeat'));

  // Re-configure the message type to have normal heartbeat comments.
  $edit = array(
    'attachments[heartbeat_comments]' => TRUE,
    'attachments[comment_comments]' => FALSE,
  );
  $this
    ->drupalPost('admin/build/heartbeat/edit/2', $edit, t('Save'));

  // Add a heartbeat comment.
  $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'));
}