function SimplenewsSendTestCase::testUpdateNewsletter in Simplenews 7.2
Same name and namespace in other branches
- 6.2 tests/simplenews.test \SimplenewsSendTestCase::testUpdateNewsletter()
- 7 tests/simplenews.test \SimplenewsSendTestCase::testUpdateNewsletter()
File
- tests/
simplenews.test, line 2561 - Simplenews test functions.
Class
- SimplenewsSendTestCase
- Test cases for creating and sending newsletters.
Code
function testUpdateNewsletter() {
// Create a second newsletter.
$this
->drupalGet('admin/config/services/simplenews');
$this
->clickLink(t('Add newsletter'));
$edit = array(
'name' => $this
->randomName(),
'description' => $this
->randomString(20),
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertText(t('Created new newsletter @name.', array(
'@name' => $edit['name'],
)));
$this
->drupalGet('node/add/simplenews');
$this
->assertText(t('Newsletter'));
$first_newsletter_id = $this
->getRandomNewsletter();
$edit = array(
'title' => $this
->randomName(),
'simplenews_newsletter[und]' => $first_newsletter_id,
);
$this
->drupalPost(NULL, $edit, 'Save');
$this
->assertTrue(preg_match('|node/(\\d+)$|', $this
->getUrl(), $matches), 'Node created.');
$node = node_load($matches[1]);
// Verify newsletter.
entity_get_controller('node')
->resetCache();
$node = node_load($node->nid);
$this
->assertEqual(SIMPLENEWS_STATUS_SEND_NOT, simplenews_issue_status($node), t('Newsletter sending not started.'));
$this
->assertEqual($first_newsletter_id, simplenews_issue_newsletter_id($node), t('Newsletter has newsletter_id ' . $first_newsletter_id . '.'));
do {
$second_newsletter_id = $this
->getRandomNewsletter();
} while ($first_newsletter_id == $second_newsletter_id);
$this
->clickLink(t('Edit'));
$update = array(
'simplenews_newsletter[und]' => $second_newsletter_id,
);
$this
->drupalPost(NULL, $update, t('Save'));
// Verify newsletter.
entity_get_controller('node')
->resetCache();
$node = node_load($node->nid);
$this
->assertEqual(SIMPLENEWS_STATUS_SEND_NOT, simplenews_issue_status($node), t('Newsletter sending not started.'));
$this
->assertEqual($second_newsletter_id, simplenews_issue_newsletter_id($node), t('Newsletter has newsletter_id ' . $second_newsletter_id . '.'));
}