You are here

public function SimpleNewsUpgradePathTestCase::assertUpgradePath in Simplenews 7

Same name and namespace in other branches
  1. 7.2 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 1891
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';
  $tid = 1;
  module_load_include('module', 'simplenews');
  simplenews_subscribe_user($mail, $tid, 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
  $this
    ->assertEqual(variable_get('simplenews_category_field'), 'taxonomy_vocabulary_1');
  $this
    ->assertTrue(field_info_instance('node', 'taxonomy_vocabulary_1', 'simplenews'));

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

  // Send newsletter.
  $this
    ->clickLink(t('Newsletter'));
  $this
    ->drupalPost(NULL, array(), t('Submit'));

  //    TODO: Maybe it would be bether to retreive the nid of the created node instead of hard code it.
  $this
    ->assertEqual(1, db_query('SELECT tid FROM {simplenews_newsletter} WHERE nid = :nid', array(
    ':nid' => 2,
  ))
    ->fetchField(), 'There is an issue associated to the correct newsletter category');

  //    @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']);
}