You are here

function OgSubscribe::testWebUserSubscribeOg in Organic groups 6.2

Same name and namespace in other branches
  1. 6 tests/og.subscribe.test \OgSubscribe::testWebUserSubscribeOg()

Test a web user subscribing and unsubscribing a group.

File

tests/og.subscribe.test, line 55

Class

OgSubscribe

Code

function testWebUserSubscribeOg() {
  $this
    ->drupalLogin($this->web_user);
  $cases = array();
  $cases['open'] = array(
    'join_button' => t('Join'),
    'request_response' => t('You are now a member of %title.', array(
      '%title' => $this->nodes['open']->title,
    )),
  );
  $cases['moderated'] = array(
    'join_button' => t('Request membership'),
    'request_response' => t('Membership request to the %title group awaits approval by an administrator.', array(
      '%title' => $this->nodes['moderated']->title,
    )),
  );
  foreach ($this->selective as $selective_id => $value) {
    if (array_key_exists($selective_id, $cases)) {
      $this
        ->_testWebUserSubscribe($selective_id, $cases[$selective_id]);
      $this
        ->_testWebUserUnsubscribeOg($selective_id);
    }
    else {

      // Assert a 403 page is given.
      $this
        ->drupalGet('og/subscribe/' . $this->nodes[$selective_id]->nid);
      $this
        ->assertResponse(403, t('User got a 403 page while trying to access @selective group subscription.', array(
        '@selective' => $selective_id,
      )));
    }
  }
}