You are here

function SimplenewsSendTestCase::testUpdateNewsletter in Simplenews 7

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

File

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

Class

SimplenewsSendTestCase
Test cases for creating and sending newsletters.

Code

function testUpdateNewsletter() {

  // Create a second category.
  $this
    ->drupalGet('admin/config/services/simplenews');
  $this
    ->clickLink(t('Add newsletter category'));
  $edit = array(
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomString(20),
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->drupalGet('node/add/simplenews');
  $this
    ->assertText(t('Newsletter category'));
  $edit = array(
    'title' => $this
      ->randomName(),
    // @todo avoid hardcoding the term id.
    'field_simplenews_term[und]' => 1,
  );
  $this
    ->drupalPost(NULL, $edit, 'Save');
  $this
    ->assertTrue(preg_match('|node/(\\d+)$|', $this
    ->getUrl(), $matches), 'Node created.');
  $node = node_load($matches[1]);

  // Verify newsletter.
  $newsletter = simplenews_newsletter_load($node->nid);
  $this
    ->assertEqual(SIMPLENEWS_STATUS_SEND_NOT, $newsletter->status, t('Newsletter sending not started.'));
  $this
    ->assertEqual(1, $newsletter->tid, t('Newsletter has tid 1'));
  $this
    ->clickLink(t('Edit'));
  $update = array(
    'field_simplenews_term[und]' => 2,
  );
  $this
    ->drupalPost(NULL, $update, t('Save'));

  // Verify newsletter.
  $newsletter = simplenews_newsletter_load($node->nid);
  $this
    ->assertEqual(SIMPLENEWS_STATUS_SEND_NOT, $newsletter->status, t('Newsletter sending not started.'));
  $this
    ->assertEqual(2, $newsletter->tid, t('Newsletter has tid 2.'));
}