function SimpleNewsAdministrationTestCase::testContentTypes in Simplenews 7.2
Same name and namespace in other branches
- 7 tests/simplenews.test \SimpleNewsAdministrationTestCase::testContentTypes()
Test content type configuration.
File
- tests/
simplenews.test, line 1663 - Simplenews test functions.
Class
- SimpleNewsAdministrationTestCase
- @todo: Newsletter node create, send draft, send final
Code
function testContentTypes() {
$admin_user = $this
->drupalCreateUser(array(
'administer blocks',
'administer content types',
'administer nodes',
'access administration pages',
'administer permissions',
'administer newsletters',
'administer simplenews subscriptions',
'bypass node access',
'send newsletter',
));
$this
->drupalLogin($admin_user);
$this
->drupalGet('admin/structure/types');
$this
->clickLink(t('Add content type'));
$edit = array(
'name' => $name = $this
->randomName(),
'type' => $type = drupal_strtolower($name),
'simplenews_content_type' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Save content type'));
// Verify that the newsletter settings are shown.
$this
->drupalGet('node/add/' . $type);
$this
->assertText(t('Newsletter'));
// Create an issue.
$edit = array(
'title' => $this
->randomName(),
);
$this
->drupalPost(NULL, $edit, 'Save');
// Send newsletter.
$this
->clickLink(t('Newsletter'));
$this
->assertText(t('Send newsletter'));
$this
->drupalPost(NULL, array(), t('Submit'));
$mails = $this
->drupalGetMails();
$this
->assertEqual('simplenews_test', $mails[0]['id']);
// @todo: Test with a custom test mail address.
$this
->assertEqual('simpletest@example.com', $mails[0]['to']);
$this
->assertEqual(t('[Drupal newsletter] @title', array(
'@title' => $edit['title'],
)), $mails[0]['subject']);
// Update the content type, remove the simpletest checkbox.
$edit = array(
'simplenews_content_type' => FALSE,
);
$this
->drupalPost('admin/structure/types/manage/' . $type, $edit, t('Save content type'));
// Verify that the newsletter settings are still shown.
// Note: Previously the field got autoremoved. We leave it remaining due to potential data loss.
$this
->drupalGet('node/add/' . $type);
$this
->assertNoText(t('Replacement patterns'));
$this
->assertText(t('Newsletter'));
// @todo: Test node update/delete.
// Delete content type.
// @todo: Add assertions.
$this
->drupalPost('admin/structure/types/manage/' . $type . '/delete', array(), t('Delete'));
}