You are here

function MessageSubscribeEmailTestHelper::setUp in Message Subscribe 7

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()

2 calls to MessageSubscribeEmailTestHelper::setUp()
MessageSubscribeEmailNotificationsTest::setUp in message_subscribe_email/message_subscribe_email.test
Sets up a Drupal site for running functional and integration tests.
MessageSubscribeEmailSubscribersTest::setUp in message_subscribe_email/message_subscribe_email.test
Sets up a Drupal site for running functional and integration tests.
2 methods override MessageSubscribeEmailTestHelper::setUp()
MessageSubscribeEmailNotificationsTest::setUp in message_subscribe_email/message_subscribe_email.test
Sets up a Drupal site for running functional and integration tests.
MessageSubscribeEmailSubscribersTest::setUp in message_subscribe_email/message_subscribe_email.test
Sets up a Drupal site for running functional and integration tests.

File

message_subscribe_email/message_subscribe_email.test, line 14
Test for the Message subscribe email module.

Class

MessageSubscribeEmailTestHelper
@file Test integration for the message_subscribe_email module.

Code

function setUp() {
  parent::setUp('message_subscribe', 'flag', 'message_subscribe_email');

  // Create node-type.
  $node_type = $this
    ->drupalCreateContentType();
  $node_type = $node_type->type;

  // Enable flags.
  $flags = flag_get_default_flags(TRUE);
  $flag = $flags['subscribe_node'];
  $flag->types[] = $node_type;
  $flag
    ->save();
  $flag
    ->enable();
  $flag = $flags['email_node'];
  $flag->types[] = $node_type;
  $flag
    ->save();
  $flag
    ->enable();

  // Reset our cache so our permissions show up.
  drupal_static_reset('flag_get_flags');

  // Reset permissions so that permissions for this flag are available.
  $this
    ->checkPermissions(array(), TRUE);
  $permissions = array(
    'flag subscribe_node',
    'unflag subscribe_node',
    'flag email_node',
    'unflag email_node',
  );
  $user1 = $this
    ->drupalCreateUser($permissions);
  $user2 = $this
    ->drupalCreateUser($permissions);

  // Create node.
  $settings = array();
  $settings['type'] = $node_type;
  $settings['uid'] = $user1->uid;
  $node = $this
    ->drupalCreateNode($settings);

  // Create a dummy message-type.
  $message_type = message_type_create('foo');
  $message_type
    ->save();
  $this->node = $node;
  $this->user1 = $user1;
  $this->user2 = $user2;
}