You are here

function SimplenewsSendTest::testSendMultipleNoCron in Simplenews 8

Send a newsletter using cron.

File

src/Tests/SimplenewsSendTest.php, line 160
Simplenews send test functions.

Class

SimplenewsSendTest
Test cases for creating and sending newsletters.

Namespace

Drupal\simplenews\Tests

Code

function testSendMultipleNoCron() {

  // Disable cron.
  $config = $this
    ->config('simplenews.settings');
  $config
    ->set('mail.use_cron', FALSE);
  $config
    ->save();

  // Verify that the newsletter settings are shown.
  $nodes = array();
  for ($i = 0; $i < 3; $i++) {
    $this
      ->drupalGet('node/add/simplenews_issue');
    $this
      ->assertText(t('Create Newsletter Issue'));
    $edit = array(
      'title[0][value]' => $this
        ->randomString(10),
      'simplenews_issue' => 'default',
      // The last newsletter shouldn't be published.
      'status[value]' => $i != 2,
    );
    $this
      ->drupalPostForm(NULL, $edit, 'Save');
    $this
      ->assertTrue(preg_match('|node/(\\d+)$|', $this
      ->getUrl(), $matches), 'Node created');
    $nodes[] = Node::load($matches[1]);

    // Verify state.
    $node = current($nodes);
    $this
      ->assertEqual(SIMPLENEWS_STATUS_SEND_NOT, $node->simplenews_issue->status, t('Newsletter not sent yet.'));
  }
}