You are here

function SimplenewsSendTestCase::setUp in Simplenews 6.2

Same name and namespace in other branches
  1. 7.2 tests/simplenews.test \SimplenewsSendTestCase::setUp()
  2. 7 tests/simplenews.test \SimplenewsSendTestCase::setUp()

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

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 SimplenewsTestCase::setUp

File

tests/simplenews.test, line 976
Simplenews test functions.

Class

SimplenewsSendTestCase
Test cases for creating and sending newsletters.

Code

function setUp() {
  parent::setUp();
  $this->user = $this
    ->drupalCreateUser(array(
    'administer newsletters',
    'send newsletter',
    'administer nodes',
    'administer simplenews subscriptions',
    'create simplenews content',
    'edit any simplenews content',
    'delete any simplenews content',
  ));
  $this
    ->drupalLogin($this->user);

  // Subscribe a few users.
  $this->subscribers = array();
  for ($i = 0; $i < 5; $i++) {
    $mail = $this
      ->randomEmail();
    $this->subscribers[$mail] = $mail;
  }
  $delimiters = array(
    ',',
    ' ',
    "\n",
  );
  $this
    ->drupalGet('admin/content/simplenews/users');
  $this
    ->clickLink(t('Mass subscribe'));
  $edit = array(
    'emails' => implode(',', $this->subscribers),
    // @todo: Don't hardcode the default tid.
    'newsletters[1]' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Subscribe'));

  // Reset the static cache.
  module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
  simplenews_mail(NULL, $message = NULL, $params = NULL, TRUE);
  simplenews_mail_mail(NULL, NULL, NULL, NULL, TRUE);
  token_get_values('global', NULL, TRUE);
}