public function OgNonMembersPublishingContentTestCase::testNonMembersPublish in Organic groups 7.2
Testing the option for non members users to publish content in the group when the group identifier passed through the URL.
File
- ./
og.test, line 2224
Class
- OgNonMembersPublishingContentTestCase
- Testing publishing content in a group for non members users.
Code
public function testNonMembersPublish() {
// Login as normal user.
$this
->drupalLogin($this->user);
// Verify the user can't publish content to the group content.
$this
->drupalGet('node/add/group-content');
$this
->assertResponse('403', t('The user can not create post in the group.'));
// Create a the group content.
$this
->drupalPost('node/add/group-content', array(
'title' => 'foo',
), t('Save'), array(
'query' => array(
'og_group_ref' => $this->group->nid,
),
));
// Verify the node belong to the group.
$query = new entityFieldQuery();
$result = $query
->entityCondition('entity_type', 'node')
->propertyCondition('title', 'foo')
->fieldCondition(OG_AUDIENCE_FIELD, 'target_id', $this->group->nid)
->execute();
$this
->assertTrue(!empty($result['node']), 'The node was added to the group.');
$result_node = $result['node'];
$node_array_keys = array_keys($result_node);
$nid = reset($node_array_keys);
$this
->drupalLogin($this->adminUser);
// Verify the audience field will remain after another user editing the
// group.
$this
->drupalpost('node/' . $nid . '/edit', array(), t('Save'));
$this
->assertText($this->group->title, 'The node is still referenced to the group.');
}