You are here

public function SimpleNewsUpgradePathTestCase::assertUpgradePath in Simplenews 7.2

Same name and namespace in other branches
  1. 7 tests/simplenews.test \SimpleNewsUpgradePathTestCase::assertUpgradePath()
2 calls to SimpleNewsUpgradePathTestCase::assertUpgradePath()
SimpleNewsUpgradePath61TestCase::testSimplenewsUpgrade in tests/simplenews.test
Test a successful upgrade.
SimpleNewsUpgradePath62TestCase::testSimplenewsUpgrade in tests/simplenews.test
Test a successful upgrade.

File

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

Class

SimpleNewsUpgradePathTestCase

Code

public function assertUpgradePath() {

  // Enable simplenews.
  $edit = array(
    'modules[Mail][simplenews][enable]' => 1,
  );
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));

  // Attempt to subscribe a mail address.
  $mail = 'new@example.org';
  $newsletter_id = 1;
  module_load_include('module', 'simplenews');
  simplenews_subscribe($mail, $newsletter_id, FALSE);
  $this
    ->drupalGet('admin/config/services/simplenews');
  $this
    ->assertText('Drupal 6 newsletter');
  $this
    ->assertText('Test');
  $this
    ->drupalGet('admin/people/simplenews');
  $this
    ->assertText('another@example.org');
  $this
    ->assertText($mail);
  $this
    ->drupalGet('admin/structure/taxonomy/newsletter');

  // Check simplenews content type.
  $this
    ->drupalGet('admin/structure/types/manage/simplenews');
  $this
    ->assertFieldChecked('edit-simplenews-content-type');
  $this
    ->drupalGet('admin/structure/types/manage/simplenews/fields');
  $this
    ->drupalGet('node/add/simplenews');
  $this
    ->assertText('Newsletter');
  $this
    ->assertText('Drupal 6 newsletter');

  // Check category field, variables and field instance should have been
  // deleted.
  $this
    ->assertEqual(variable_get('simplenews_category_field', 'dummy'), 'dummy');
  $this
    ->assertFalse(field_info_instance('node', 'taxonomy_vocabulary_1', 'simplenews'));

  // Create an issue.
  $edit = array(
    'title' => $this
      ->randomName(),
  );
  $this
    ->drupalPost(NULL, $edit, 'Save');

  // Send newsletter.
  $this
    ->clickLink(t('Newsletter'));
  $this
    ->drupalPost(NULL, array(), t('Submit'));
  entity_get_controller('node')
    ->resetCache(array(
    2,
  ));
  $node = node_load(2);
  $this
    ->assertEqual(1, simplenews_issue_newsletter_id($node), 'There is an issue associated to the correct newsletter');

  //    @todo Mails are not correctly returned
  //    $mails = $this->drupalGetMails();
  //    debug($mails);
  //    $this->assertEqual('simplenews_test', $mails[0]['id']);
  //    $this->assertEqual('user@example.com', $mails[0]['to']);
  //    $this->assertEqual(t('[Drupal newsletter] @title', array('@title' => $edit['title'])), $mails[0]['subject']);
  // Make sure that new categories can be created.
  $edit = array(
    'name' => $this
      ->randomName(),
  );
  $this
    ->drupalPost('admin/config/services/simplenews/add', $edit, t('Save'));
  $this
    ->assertResponse(200);
  $this
    ->assertText($edit['name']);
}