You are here

function MessageSubscribeSubscribersTest::testEntityAccess in Message Subscribe 7

Assert subscribers list is entity-access aware.

File

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

Class

MessageSubscribeSubscribersTest
Test getting subscribes from context.

Code

function testEntityAccess() {

  // Make sure we are notifying ourselves for this test.
  variable_set('message_subscribe_notify_own_actions', TRUE);
  $message = message_create('foo', array());
  $node = $this->node;
  $node->status = NODE_NOT_PUBLISHED;
  node_save($node);

  // Add permission to view own unpublished content.
  user_role_change_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'view own unpublished content' => TRUE,
  ));

  // Set the node to be unpublished.
  $user1 = $this->user1;
  $user2 = $this->user2;
  $subscribe_options['entity access'] = TRUE;
  $uids = message_subscribe_get_subscribers('node', $node, $message, $subscribe_options);
  $this
    ->assertEqual(array_keys($uids), array(
    $user1->uid,
  ), 'Only user with access to node returned for subscribers list.');
  $subscribe_options['entity access'] = FALSE;
  $uids = message_subscribe_get_subscribers('node', $node, $message, $subscribe_options);
  $this
    ->assertEqual(array_keys($uids), array(
    $user1->uid,
    $user2->uid,
  ), 'All users (even without access) returned for subscribers list.');
}