function OgNodeAccess::testStrictAccessNodeCreate in Organic groups 7.2
Test access to node create on strict mode.
File
- ./
og.test, line 190
Class
- OgNodeAccess
- Test Group node access. This will test nodes that are groups and group content.
Code
function testStrictAccessNodeCreate() {
// Set Node access strict variable.
variable_set('og_node_access_strict', TRUE);
$editor_user = $this->editor_user;
$this
->drupalLogin($editor_user);
$this
->drupalGet('node/add/article');
$this
->assertResponse('200', t('User can access node create with non-required field.'));
$instance = field_info_instance('node', OG_AUDIENCE_FIELD, 'article');
$instance['required'] = TRUE;
field_update_instance($instance);
$this
->drupalGet('node/add/article');
$this
->assertResponse('403', t('User cannot access node create with required field.'));
// Test OG's create permission for a group member.
$editor_user = user_load($editor_user->uid);
og_group('node', $this->group1, array(
'entity' => $editor_user,
));
$roles = array_flip(og_roles('node', 'page'));
$permissions = array(
'create article content' => 0,
'update own article content' => 1,
'update any article content' => 1,
);
// Add update permission.
og_role_change_permissions($roles[OG_AUTHENTICATED_ROLE], $permissions);
$this
->drupalGet('node/add/article');
$this
->assertResponse('403', 'Group member cannot create node.');
// Add create permission.
$permissions = array(
'create article content' => 1,
'update own article content' => 0,
'update any article content' => 0,
);
og_role_change_permissions($roles[OG_AUTHENTICATED_ROLE], $permissions);
$this
->drupalGet('node/add/article');
$this
->assertResponse('200', 'Group member can create node.');
}