You are here

function OgContext::testOgGidContex in Organic groups 6.2

Test the group Id (gids) passed in the URL.

File

tests/og.context.test, line 118

Class

OgContext

Code

function testOgGidContex() {
  $group_node = node_load($this->group_nid);
  $group_node_second = node_load($this->group_nid_second);
  $title = $this
    ->randomName(8);
  $body = $this
    ->randomName(32);
  $path = 'node/add/' . str_replace('_', '-', $this->post_type);
  $gids = 'gids[]=' . $this->group_nid;

  // Pass 1st group in URL and submit.
  unset($edit);
  $edit = array(
    'title' => $title,
    'body' => $body,
  );
  $this
    ->drupalPost($path, $edit, t('Save'), array(
    'query' => $gids,
  ));
  $this
    ->assertText($group_node->title, t('Pass 1st group in URL and submit.'));

  // Pass 1st group in URL but edit form to select 2nd group.
  unset($edit);
  $edit = array(
    'title' => $title,
    'body' => $body,
    'og_groups[' . $this->group_nid . ']' => FALSE,
    'og_groups[' . $this->group_nid_second . ']' => TRUE,
  );
  $this
    ->drupalGet($path, array(
    'query' => $gids,
  ));
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->assertText($group_node_second->title, t('Pass 1st group in URL but edit form to select 2nd group.'));

  // Pass both groups in URL and submit.
  unset($edit);
  $edit = array(
    'title' => $title,
    'body' => $body,
  );
  $gids = 'gids[]=' . $this->group_nid . ',' . $this->group_nid_second;
  $this
    ->drupalPost($path, $edit, t('Save'), array(
    'query' => $gids,
  ));
  $this
    ->assertText($group_node->title, t('Pass both groups in URL and submit - 1st group found'));
  $this
    ->assertText($group_node_second->title, t('Pass both groups in URL and submit - 2ndst group found'));

  // Pass both groups in URL and select none.
  unset($edit);
  $edit = array(
    'title' => $title,
    'body' => $body,
    'og_groups[' . $this->group_nid . ']' => FALSE,
    'og_groups[' . $this->group_nid_second . ']' => FALSE,
  );
  $this
    ->drupalGet($path, array(
    'query' => $gids,
  ));
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->assertNoText($group_node->title, t(' Pass both groups in URL and select none - 1st group not found, as expected.'));
  $this
    ->assertNoText($group_node_second->title, t(' Pass both groups in URL and select none - 2st group not found, as expected.'));
}