You are here

public function OgDeleteOrphansTestCase::testEditGroupContentAfterDeletingGroup in Organic groups 7.2

Tests editing content that belongs to a deleted group.

Tests if content belonging to multiple groups can be edited without issues after deleting one of the groups.

File

./og.test, line 2093

Class

OgDeleteOrphansTestCase
Testing for deleting orphans group content.

Code

public function testEditGroupContentAfterDeletingGroup() {
  $account = $this
    ->drupalCreateUser(array(
    '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,
  ));

  // Try to edit the group content node, using the UI.
  $this
    ->drupalPost('node/' . $group_content->nid . '/edit', array(), 'Save');
  $this
    ->assertText($this->node_type . ' Lorem ipsum has been updated.');

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

  // Try again to edit the group content node.
  $this
    ->drupalPost('node/' . $group_content->nid . '/edit', array(), 'Save');
  $this
    ->assertText($this->node_type . ' Lorem ipsum has been updated.');
}