You are here

function HeartbeatUnit::testHeartbeatLogger in Heartbeat 6.3

Tests if a heartbeat message is logged for an event.

File

tests/heartbeat_unit.test, line 34

Class

HeartbeatUnit

Code

function testHeartbeatLogger() {
  $user = $this
    ->drupalCreateUser(array(
    'configure heartbeat',
    'configure heartbeat messages',
    'delete heartbeat activity logs',
    'view heartbeat messages',
  ));
  $this
    ->drupalLogin($user);
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'title' => 'my first post',
  ));
  $message = db_result(db_query("SELECT * FROM {hb_activity} hba INNER JOIN {heartbeat_messages} hbm ON hba.message_id = hbm.message_id WHERE uaid = 1"));
  $this
    ->assertTrue(!empty($messages), 'Tests if message was logged', t('Heartbeat log'));
  $this
    ->assertEqual($message->uid, $user->uid, 'Actor was logged correctly', t('Heartbeat log'));
  $this
    ->assertEqual($message->nid_target, $node->nid, 'Node was logged correctly', t('Heartbeat log'));
}