You are here

function MessageSubscribeContextTest::testGetBasicContext in Message Subscribe 7

File

./message_subscribe.test, line 118
Test for the Message subscribe module.

Class

MessageSubscribeContextTest
Test getting context from entity.

Code

function testGetBasicContext() {
  $node = $this->node;
  $group = $this->group;
  $comment = $this->comment;

  // Get context from comment.
  $context = message_subscribe_get_basic_context('comment', $comment);
  $expected_context = array();
  $expected_context['comment'] = drupal_map_assoc(array(
    $comment->cid,
  ));
  $expected_context['node'] = drupal_map_assoc(array(
    $node->nid,
    $group->nid,
  ));
  $expected_context['user'] = drupal_map_assoc(array(
    $comment->uid,
    $node->uid,
    $group->uid,
  ));
  $expected_context['taxonomy_term'] = drupal_map_assoc($this->tids);
  $this
    ->assertEqual($context, $expected_context, 'Correct context from comment.');

  // Pass existing context.
  $subscribe_options = array(
    'skip context' => TRUE,
  );
  $original_context = array(
    'node' => array(
      1 => 1,
    ),
    'user' => array(
      1 => 1,
    ),
  );
  $context = message_subscribe_get_basic_context('comment', $comment, $subscribe_options, $original_context);
  $this
    ->assertEqual($original_context, $context, 'Correct context when skiping context.');
}