You are here

function PrivatemsgGroupsTestCase::setUp in Privatemsg 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

privatemsg_groups/privatemsg_groups.test, line 21
This file contains tests for the privatemsg groups module

Class

PrivatemsgGroupsTestCase
Test cases for the privatemsg_groups module.

Code

function setUp() {
  parent::setUp('privatemsg', 'privatemsg_groups', 'privatemsg_filter', 'pm_block_user', 'og');

  // Add OG group field to a the node's "page" bundle.
  og_create_field(OG_GROUP_FIELD, 'node', 'page');

  // Create group managers for these tests.
  $this->group1_manager = $this
    ->drupalCreateUser(array(
    'administer group',
    'access content',
    'create page content',
    'edit own page content',
    'read privatemsg',
    'write privatemsg',
    'write privatemsg to all organic groups',
    'view organic groups recipients',
  ));
  $this->group2_manager = $this
    ->drupalCreateUser(array(
    'administer group',
    'access content',
    'create page content',
    'edit own page content',
    'read privatemsg',
    'write privatemsg',
    'write privatemsg to own organic groups',
    'view organic groups recipients',
  ));

  // Create group members for these tests
  $this->user1 = $this
    ->drupalCreateUser(array(
    'read privatemsg',
    'write privatemsg',
  ));

  // Create group nodes.
  $settings = array(
    'type' => 'page',
    OG_GROUP_FIELD . '[und][0][value]' => 1,
    'uid' => $this->group1_manager->uid,
  );
  $this->group1 = $this
    ->drupalCreateNode($settings);
  $settings['uid'] = $this->group2_manager->uid;
  $this->group2 = $this
    ->drupalCreateNode($settings);

  // Add user as group member.
  og_group('node', $this->group1->nid, array(
    'entity' => $this->user1->uid,
  ));
  drupal_static_reset('privatemsg_recipient_get_types');
}