You are here

function SimplenewsMonitoringTest::testSensors in Simplenews 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/SimplenewsMonitoringTest.php \Drupal\Tests\simplenews\Kernel\SimplenewsMonitoringTest::testSensors()
  2. 3.x tests/src/Kernel/SimplenewsMonitoringTest.php \Drupal\Tests\simplenews\Kernel\SimplenewsMonitoringTest::testSensors()

Tests individual sensors.

File

tests/src/Kernel/SimplenewsMonitoringTest.php, line 31
Simplenews monitoring test functions.

Class

SimplenewsMonitoringTest
Tests for simplenews sensor.

Namespace

Drupal\Tests\simplenews\Kernel

Code

function testSensors() {
  $this
    ->installConfig(array(
    'system',
  ));
  $this
    ->installConfig(array(
    'node',
  ));
  $this
    ->installConfig(array(
    'simplenews',
  ));
  $this
    ->installEntitySchema('monitoring_sensor_result');
  $this
    ->installSchema('simplenews', 'simplenews_mail_spool');

  // No spool items - status OK.
  $result = $this
    ->runSensor('simplenews_pending');
  $this
    ->assertEqual($result
    ->getValue(), 0);

  // Crate a spool item in state pending.
  \Drupal::service('simplenews.spool_storage')
    ->addMail(array(
    'mail' => 'mail@example.com',
    'entity_type' => 'node',
    'entity_id' => 1,
    'newsletter_id' => 'default',
    'snid' => 1,
    'data' => array(
      'data' => 'data',
    ),
  ));
  $result = $this
    ->runSensor('simplenews_pending');
  $this
    ->assertEqual($result
    ->getValue(), 1);
}