You are here

function MessageSubscribeSubscribersTest::testGetSubscribersExcludeSelf in Message Subscribe 7

Testing the exclusion of the entity author from the subscribers lists.

File

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

Class

MessageSubscribeSubscribersTest
Test getting subscribes from context.

Code

function testGetSubscribersExcludeSelf() {

  // Test the affect of the variable when set to FALSE (do not notify self).
  variable_set('message_subscribe_notify_own_actions', FALSE);
  $message = message_create('foo', array(
    'uid' => $this->user1->uid,
  ));
  $node = $this->node;
  $user1 = $this->user1;
  $user2 = $this->user2;
  $uids = message_subscribe_get_subscribers('node', $node, $message);

  // Assert subscribers data.
  $expected_uids = array(
    $user2->uid => array(
      'notifiers' => array(),
      'flags' => array(
        'subscribe_node',
        'subscribe_user',
      ),
    ),
  );
  $this
    ->assertEqual($uids, $expected_uids, 'All subscribers except for the triggering user were fetched.');

  // Test the affect of the variable when set to TRUE (Notify self).
  variable_set('message_subscribe_notify_own_actions', TRUE);
  $uids = message_subscribe_get_subscribers('node', $node, $message);

  // Assert subscribers data.
  $expected_uids = array(
    $user1->uid => array(
      'notifiers' => array(),
      'flags' => array(
        'subscribe_node',
      ),
    ),
    $user2->uid => array(
      'notifiers' => array(),
      'flags' => array(
        'subscribe_node',
        'subscribe_user',
      ),
    ),
  );
  $this
    ->assertEqual($uids, $expected_uids, 'All subscribers including the triggering user were fetched.');
}