protected function SimplenewsDemoTest::testInstalled in Simplenews 8
Asserts the demo module has been installed successfully.
File
- modules/
simplenews_demo/ src/ Tests/ SimplenewsDemoTest.php, line 43 - Contains \Drupal\simplenews_demo\Tests\SimplenewsDemoTest.
Class
- SimplenewsDemoTest
- Tests the demo module for Simplenews.
Namespace
Drupal\simplenews_demo\TestsCode
protected function testInstalled() {
// Check for the two subscription blocks.
$this
->assertText('Simplenews multiple subscriptions');
$this
->assertText('Stay informed - subscribe to our newsletters.');
$this
->assertText('Simplenews subscription');
$this
->assertText('Stay informed - subscribe to our newsletter.');
$this
->drupalGet('admin/config/services/simplenews');
$this
->clickLink(t('Edit'));
// Assert default description is present.
$this
->assertEqual('This is an example newsletter. Change it.', (string) $this
->xpath('//textarea[@id="edit-description"]')[0]);
$from_name = $this
->xpath('//input[@id="edit-from-name"]')[0];
$from_address = $this
->xpath('//input[@id="edit-from-address"]')[0];
$this
->assertEqual('Drupal', (string) $from_name['value']);
$this
->assertEqual('simpletest@example.com', (string) $from_address['value']);
// Assert demo newsletters.
$this
->drupalGet('admin/config/services/simplenews');
$this
->assertText(t('Press releases'));
$this
->assertText(t('Special offers'));
$this
->assertText(t('Weekly content update'));
// Assert demo newsletters sent.
$this
->drupalGet('admin/content/simplenews');
$this
->assertText('Scheduled weekly content newsletter issue');
$this
->assertText('Sent press releases');
$this
->assertText('Unpublished press releases');
$this
->assertText('Pending special offers');
$this
->assertText('Stopped special offers');
$this
->assertText('Scheduled weekly content newsletter issue - Week ');
$this
->assertRaw(t('Newsletter issue sent to 2 subscribers.'));
// @todo Set back to 'out of 3'.
// https://www.drupal.org/project/simplenews/issues/3052727
$this
->assertRaw(t('Newsletter issue is pending, 0 mails sent out of 0.'));
// Weekly newsletter.
$this
->assertRaw(t('Newsletter issue sent to 1 subscribers.'));
// Assert demo subscribers.
$this
->drupalGet('admin/people/simplenews');
$this
->assertText('a@example.com');
$this
->assertText('b@example.com');
$this
->assertText('demouser1@example.com');
}