function OgBehaviorHandlerTestCase::testGroupAudienceFieldSkipBehavior in Organic groups 7.2
Test skipping OgBehaviorHandler.
File
- ./
og.test, line 1906
Class
Code
function testGroupAudienceFieldSkipBehavior() {
$user1 = $this
->drupalCreateUser();
$user2 = $this
->drupalCreateUser();
$entity1 = entity_create('entity_test', array(
'name' => 'main',
'uid' => $user1->uid,
));
$wrapper = entity_metadata_wrapper('entity_test', $entity1);
$wrapper->{OG_GROUP_FIELD}
->set(1);
$wrapper
->save();
$settings = array();
$settings['type'] = $this->group_content;
$settings['uid'] = $user2->uid;
$node = $this
->drupalCreateNode($settings);
og_group('entity_test', $entity1, array(
'entity_type' => 'node',
'entity' => $node,
));
$node->og_group_on_save = array(
'group_type' => 'entity_test',
'gid' => $entity1->pid,
);
node_save($node);
$this
->assertFalse(og_get_entity_groups('node', $node), 'Widget behavior removed group association as expected.');
$node = node_load($node->nid);
$node->og_group_on_save = array(
'group_type' => 'entity_test',
'gid' => $entity1->pid,
);
$node->skip_og_membership = TRUE;
node_save($node);
$gids = og_get_entity_groups('node', $node);
$this
->assertEqual(array_values($gids['entity_test']), array(
$entity1->pid,
), 'Widget behavior was skipped and removed group association as expected.');
}