You are here

function OgFieldWidgetTestCase::testHiddenGroupIds in Organic groups 7.2

Test non-accessible group IDs are saved, upon form submit.

File

./og.test, line 1175

Class

OgFieldWidgetTestCase
Test the complex widget.

Code

function testHiddenGroupIds() {
  $user1 = $this
    ->drupalCreateUser(array(
    'administer group',
    'access content',
    'create post content',
  ));
  $user2 = $this
    ->drupalCreateUser(array(
    'access content',
    'create post content',
  ));

  // Create group nodes.
  $settings = array(
    'type' => 'group',
    OG_GROUP_FIELD . '[und][0][value]' => 1,
  );
  $settings['uid'] = $user1->uid;
  $group1 = $this
    ->drupalCreateNode($settings);
  $settings['uid'] = $user2->uid;
  $group2 = $this
    ->drupalCreateNode($settings);
  $settings = array(
    'type' => 'post',
  );
  $settings['uid'] = $user1->uid;
  $post1 = $this
    ->drupalCreateNode($settings);
  og_group('node', $group1->nid, array(
    'entity_type' => 'node',
    'entity' => $post1,
  ));
  og_group('node', $group2->nid, array(
    'entity_type' => 'node',
    'entity' => $post1,
  ));
  $this
    ->drupalLogin($user2);
  $this
    ->drupalPost("node/{$post1->nid}/edit", array(), 'Save');

  // Assert post still belongs to both groups, although user was able
  // to select only one.
  $gids = og_get_entity_groups('node', $post1);
  $this
    ->assertEqual(count($gids['node']), 2, 'Hidden groups remained.');
}