You are here

function OgContext::testOgContex in Organic groups 6

Same name and namespace in other branches
  1. 6.2 tests/og.context.test \OgContext::testOgContex()

Test the context in different situations.

File

tests/og.context.test, line 61

Class

OgContext

Code

function testOgContex() {

  // Prepare all the tests, with the URLs and if the block should appear or
  // be hidden.
  $tests = array(
    'group node view' => array(
      'path' => 'node/' . $this->group_nid,
      'display' => TRUE,
    ),
    'group node add' => array(
      'path' => 'node/add/' . $this->group_type,
      'display' => FALSE,
    ),
    'group post view' => array(
      'path' => 'node/' . $this->post_nid,
      'display' => TRUE,
    ),
    'group post edit' => array(
      'path' => 'node/' . $this->post_nid . '/edit',
      'display' => TRUE,
    ),
    'group post delete' => array(
      'path' => 'node/' . $this->post_nid . '/delete',
      'display' => TRUE,
    ),
    'group post add' => array(
      'path' => 'node/add/' . $this->post_type,
      'display' => FALSE,
    ),
    'group post add with ?gids[] in the URL' => array(
      'path' => 'node/add/' . $this->post_type,
      'query' => 'gids[]=' . $this->group_nid,
      'display' => TRUE,
    ),
    "OG's menu callback (group manage)" => array(
      'path' => 'og/manage/' . $this->group_nid,
      'display' => TRUE,
    ),
  );
  foreach ($tests as $test_name => $test) {
    $this
      ->drupalGet($test['path'], !empty($test['query']) ? array(
      'query' => $test['query'],
    ) : array());
    if ($test['display']) {
      $assert_func = 'assertText';
      $display = t('displayed');
    }
    else {
      $assert_func = 'assertNoText';
      $display = t('hidden');
    }

    // Confirm that the block is being displayed/ hidden.
    $this
      ->{$assert_func}(t('My membership'), t('Block successfully being @display on the %test_name page.', array(
      '@display' => $display,
      '%test_name' => $test_name,
    )));
  }
}