You are here

public function OgUserCanPublishGroupContentTypeOnlyInGroup::testNonGroupUserCanPostGroupContentOutsideGroup in Organic groups 7.2

Verify that non-group user can post group content outside of a group.

File

./og.test, line 2358

Class

OgUserCanPublishGroupContentTypeOnlyInGroup
Verify that users only with OG permissions can post only inside a group

Code

public function testNonGroupUserCanPostGroupContentOutsideGroup() {
  $this
    ->drupalLogin($this->site_user);

  // Set node access strict variable to FALSE for posting outside groups.
  variable_set('og_node_access_strict', FALSE);

  // Verify that the user can publish group content outside a group.
  $node_title = $this
    ->randomName();
  $this
    ->drupalPost('node/add', array(
    'title' => $node_title,
  ), t('Save'));
  $params = array(
    '@type' => $this->group_content->type,
    '@title' => $node_title,
  );
  $this
    ->assertText(format_string("@type @title has been created.", $params), "The user can create content outside a group.");

  // Check the user can edit the node.
  $query = new entityFieldQuery();
  $result = $query
    ->entityCondition('entity_type', 'node')
    ->propertyCondition('title', $node_title)
    ->execute();
  $node_title = $this
    ->randomName();
  $edit = array(
    'title' => $node_title,
  );
  $this
    ->drupalPost('node/' . reset($result['node'])->nid . '/edit', $edit, t('Save'));
  $this
    ->assertText($this->group_content->type . " " . $node_title . " has been updated.", "The user can edit content outside a group.");
}