public function OgAccessModeratedGroup::setUp in Organic groups 7.2
Sets up a Drupal site for running functional and integration tests.
Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides DrupalWebTestCase::setUp
See also
DrupalWebTestCase::prepareDatabasePrefix()
DrupalWebTestCase::changeDatabasePrefix()
DrupalWebTestCase::prepareEnvironment()
File
- og_access/
og_access.test, line 424 - Test organic groups access module.
Class
- OgAccessModeratedGroup
- Tests moderated group memberships.
Code
public function setUp() {
parent::setUp(array(
'og',
'og_access',
'og_ui',
));
node_access_rebuild();
// Creating the content type and the necessary fields for this test.
$content_type = $this
->drupalCreateContentType();
og_create_field(OG_GROUP_FIELD, 'node', $content_type->type);
og_create_field(OG_ACCESS_FIELD, 'node', $content_type->type);
// Creating a private group, and a user.
$this->group = $this
->drupalCreateNode(array(
'type' => $content_type->type,
));
$wrapper = entity_metadata_wrapper('node', $this->group);
$wrapper->{OG_GROUP_FIELD}
->set(TRUE);
$wrapper->{OG_ACCESS_FIELD}
->set(1);
$wrapper
->save();
$this->user = $this
->drupalCreateUser();
// Remove ability to apply without approval, but still allow them to subscribe.
$roles = og_roles('node', $this->group->type);
og_role_revoke_permissions(array_search(OG_ANONYMOUS_ROLE, $roles), array(
'subscribe without approval',
));
og_role_grant_permissions(array_search(OG_ANONYMOUS_ROLE, $roles), array(
'subscribe',
));
$this
->drupalLogin($this->user);
}