public function SimplenewsRecipientHandlerTest::testNewUsers in Simplenews 3.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/SimplenewsRecipientHandlerTest.php \Drupal\Tests\simplenews\Functional\SimplenewsRecipientHandlerTest::testNewUsers()
Tests the "new users" recipient handler.
File
- tests/
src/ Functional/ SimplenewsRecipientHandlerTest.php, line 65
Class
- SimplenewsRecipientHandlerTest
- Test cases for creating and sending newsletters.
Namespace
Drupal\Tests\simplenews\FunctionalCode
public function testNewUsers() {
// Mark users 4&5 as logged in, so that the recipients are users 1-3.
$users = $this
->createUsers();
foreach (array_slice($users, -2) as $user) {
$user
->setLastAccessTime(time())
->save();
}
$this
->drupalGet('node/add/simplenews_issue');
$edit = [
'title[0][value]' => $this
->randomString(10),
'simplenews_issue[target_id]' => 'default',
'simplenews_issue[handler]' => 'simplenews_new_users',
];
$this
->submitForm($edit, 'Save');
$this
->clickLink(t('Newsletter'));
$this
->assertText(t('Send newsletter issue to 3 subscribers.'));
$this
->submitForm([], 'Send now');
$this
->checkRecipients(array_slice($users, 0, 3));
}