public function OgNonMembersPublishingContentTestCase::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.test, line 2182
Class
- OgNonMembersPublishingContentTestCase
- Testing publishing content in a group for non members users.
Code
public function setUp() {
parent::setUp('og_test', 'entityreference_prepopulate');
// Creating a user.
$this->user = $this
->drupalCreateUser();
// Creating admin.
$this->adminUser = $this
->drupalCreateUser(array(
'bypass node access',
'administer group',
));
// Create a group content type.
$this
->drupalCreateContentType(array(
'name' => 'Group',
'type' => 'group',
));
og_create_field(OG_GROUP_FIELD, 'node', 'group');
// Create the group.
$settings = array(
'type' => 'group',
OG_GROUP_FIELD . '[und][0][value]' => 1,
'uid' => 1,
);
$this->group = $this
->drupalCreateNode($settings);
// Create the group content.
$this
->drupalCreateContentType(array(
'name' => 'Group content',
'type' => 'group_content',
));
// Attach the audience field and enable the prepopulate behavior.
$og_field = og_fields_info(OG_AUDIENCE_FIELD);
$og_field['instance']['settings']['behaviors']['prepopulate'] = array(
'status' => TRUE,
'action' => 'none',
);
og_create_field(OG_AUDIENCE_FIELD, 'node', 'group_content', $og_field);
// Add permission to the group.
$og_roles = og_roles('node', 'group');
$rid = array_search(OG_ANONYMOUS_ROLE, $og_roles);
og_role_change_permissions($rid, array(
'create group_content content' => 1,
));
}