You are here

public function OgDeleteOrphansTestCase::testGroupContentNodeAccessAfterDeletingGroupAndWhenUsingQueue in Organic groups 7.2

Tests calling node_access() on content that belongs to a deleted group.

Tests if node_access() can be called for content that has a reference to a no longer existing group when OG is configured to use the delete queue.

File

./og.test, line 2128

Class

OgDeleteOrphansTestCase
Testing for deleting orphans group content.

Code

public function testGroupContentNodeAccessAfterDeletingGroupAndWhenUsingQueue() {

  // Configure OG to use queue for deleting pending content.
  variable_set('og_use_queue', TRUE);
  $account = $this
    ->drupalCreateUser(array(
    'access content',
    'edit own ' . $this->node_type . ' content',
  ));
  $this
    ->drupalLogin($account);

  // Create two groups.
  $first_group = $this
    ->drupalCreateNode(array(
    'type' => $this->group_type,
  ));
  $second_group = $this
    ->drupalCreateNode(array(
    'type' => $this->group_type,
  ));

  // Create group content, assign it to both groups.
  $group_content = $this
    ->drupalCreateNode(array(
    'type' => $this->node_type,
    'title' => 'Lorem ipsum',
    'uid' => $account->uid,
  ));
  og_group('node', $first_group, array(
    'entity_type' => 'node',
    'entity' => $group_content,
  ));
  og_group('node', $second_group, array(
    'entity_type' => 'node',
    'entity' => $group_content,
  ));

  // Display a list of my nodes, that uses node_access() to check if links may
  // be displayed.
  $this
    ->drupalGet('og_test/my_content');
  $this
    ->assertText('Lorem ipsum');

  // Delete the first group.
  node_delete($first_group->nid);

  // Display a list of my nodes again, to ensure nothing changed.
  $this
    ->drupalGet('og_test/my_content');
  $this
    ->assertNoText('EntityMalformedException');
  $this
    ->assertText('Lorem ipsum');
}