You are here

function SimplenewsSendTestCase::testUpdateNewsletter in Simplenews 6.2

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

File

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

Class

SimplenewsSendTestCase
Test cases for creating and sending newsletters.

Code

function testUpdateNewsletter() {

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

  // Verify newsletter.
  $this
    ->assertEqual(SIMPLENEWS_STATUS_SEND_NOT, $node->simplenews['s_status'], t('Newsletter sending not started.'));
  $this
    ->assertEqual(1, $node->simplenews['tid'], t('Newsletter has tid 1'));
  $this
    ->clickLink(t('Edit'));
  $update = array(
    'taxonomy[' . variable_get('simplenews_vid', '') . ']' => 2,
  );
  $this
    ->drupalPost(NULL, $update, t('Save'));

  // Verify newsletter.
  $node = node_load($node->nid, NULL, TRUE);
  $this
    ->assertEqual(SIMPLENEWS_STATUS_SEND_NOT, $node->simplenews['s_status'], t('Newsletter sending not started.'));
  $this
    ->assertEqual(2, $node->simplenews['tid'], t('Newsletter has tid 2.'));
}