You are here

public function SimplenewsSendTest::testSendMultipleNoCron in Simplenews 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Functional/SimplenewsSendTest.php \Drupal\Tests\simplenews\Functional\SimplenewsSendTest::testSendMultipleNoCron()

Send multiple newsletters without cron.

File

tests/src/Functional/SimplenewsSendTest.php, line 155

Class

SimplenewsSendTest
Test cases for creating and sending newsletters.

Namespace

Drupal\Tests\simplenews\Functional

Code

public 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 = [];
  for ($i = 0; $i < 3; $i++) {
    $this
      ->drupalGet('node/add/simplenews_issue');
    $this
      ->assertText(t('Create Newsletter Issue'));
    $edit = [
      'title[0][value]' => $this
        ->randomString(10),
      'simplenews_issue[target_id]' => 'default',
      // The last newsletter shouldn't be published.
      'status[value]' => $i != 2,
    ];
    $this
      ->drupalPostForm(NULL, $edit, 'Save');
    $this
      ->assertEqual(1, 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.'));
  }
}