You are here

function OgContextTestCase::testGettingGroupContext in Organic groups 7.2

Testing of the og_context returning value. Should return group id if user has permissions and NULL if he doesn't.

File

og_context/og_context.test, line 49
Test organic groups context module.

Class

OgContextTestCase
Test OG access.

Code

function testGettingGroupContext() {
  $this
    ->drupalLogin($this->user1);

  // User can get the group context.
  $this
    ->assertTrue(og_context('node', $this->group_node));

  // Unpublishing the group node.
  $this->group_node->status = FALSE;
  node_save($this->group_node);
  $this->group_node = node_load($this->group_node->nid);

  // Other user should not get the group context
  $this
    ->assertFalse(og_context('node', $this->group_node, $this->user2));

  // Anybody should get existing context if checking access is FALSE.
  $this
    ->assertTrue(og_context('node', $this->group_node, $this->user2, FALSE));
}