You are here

function OgWiki::testOgWiki in Organic groups 6.2

Same name and namespace in other branches
  1. 6 tests/og_wiki.test \OgWiki::testOgWiki()

Test the simple case of creation of a group node and a group post by the same user.

File

tests/og_wiki.test, line 42

Class

OgWiki

Code

function testOgWiki() {

  // Create a group node content type.
  $og_group_type = $this
    ->drupalCreateContentType();
  variable_set('og_content_type_usage_' . $og_group_type->name, 'group');

  // Create a group post content type.
  $og_post_type = $this
    ->drupalCreateContentType();
  variable_set('og_content_type_usage_' . $og_post_type->name, 'group_post_wiki');

  // Rebuild the menu so the new content types will appear in the menu.
  menu_rebuild();

  // Create a group node.
  $gid = $this
    ->addOgGroup($og_group_type->name);

  // Create a post node.
  $nid = $this
    ->addOgPost($og_post_type->name, array(
    $gid,
  ));

  // Login web user.
  $this
    ->drupalLogin($this->web_user);

  // Web user isn't isn't a member so cannot edit the node.
  $this
    ->drupalGet("node/{$nid}/edit");
  $this
    ->assertResponse(403, t('Non-group member got a 403 page while trying to access edit wiki post.'));

  // Subscribe web user to the group.
  $this
    ->drupalGet('og/subscribe/' . $gid);
  $this
    ->drupalPost(NULL, array(), t('Join'));

  // Re-try to edit.
  $this
    ->drupalGet("node/{$nid}/edit");
  $this
    ->assertResponse(200, t('Group member is allowed to edit a wiki post.'));
}