You are here

private function SimplenewsStatisticsTestCase::createNewsletter in Simplenews Statistics 7

Same name and namespace in other branches
  1. 7.2 tests/simplenews_statistics.test \SimplenewsStatisticsTestCase::createNewsletter()

Function that will create a newsletter in the default category

See also

SimplenewsSourceTestCase::testSendHTML

1 call to SimplenewsStatisticsTestCase::createNewsletter()
SimplenewsStatisticsTestCase::createAndPublishNewsletter in tests/simplenews_statistics.test
Function that will create a newsletter in the default category and publish it

File

tests/simplenews_statistics.test, line 58
Simplenews Statistics test functions.

Class

SimplenewsStatisticsTestCase
@file Simplenews Statistics test functions.

Code

private function createNewsletter() {

  // Use custom testing mail system to support HTML mails.
  variable_set('mail_system', array(
    'default-system' => 'SimplenewsHTMLTestingMailSystem',
  ));

  // Set the format to HTML.
  $this
    ->drupalGet('admin/config/services/simplenews');
  $this
    ->clickLink(t('edit newsletter category'));
  $edit_category = array(
    'format' => 'html',
    // Use umlaut to provoke mime encoding.
    'from_name' => 'Drupäl Simplenews Statistic Testing',
    // @todo: load the website default email
    'from_address' => $this
      ->randomEmail(),
    // Request a confirmation receipt.
    'receipt' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit_category, t('Save'));
  $body_text = <<<TEXT
Mail token: <strong>[simplenews-subscriber:mail]</strong><br />
add a link in the mail to drupal.org so we can test later <br />
<a title="Simplenews Statistics Link" href="http://drupal.org/project/simplenews_statistics ">Simplenews Statistics Module Page</a>
TEXT;
  $edit = array(
    'title' => $this
      ->randomName(),
    'body[und][0][value]' => $body_text,
  );
  $this
    ->drupalPost('node/add/simplenews', $edit, 'Save');
  $this
    ->assertTrue(preg_match('|node/(\\d+)$|', $this
    ->getUrl(), $matches), 'Node created');
  $node = node_load($matches[1]);
  $this->newsletter_nid = $node->nid;
}