You are here

public function SimplenewsMonitoringTest::testSensors in Simplenews 8.2

Same name and namespace in other branches
  1. 8 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 27

Class

SimplenewsMonitoringTest
Tests for simplenews sensor.

Namespace

Drupal\Tests\simplenews\Kernel

Code

public function testSensors() {
  $this
    ->installConfig([
    'system',
  ]);
  $this
    ->installConfig([
    'node',
  ]);
  $this
    ->installConfig([
    '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([
    'entity_type' => 'node',
    'entity_id' => 1,
    'newsletter_id' => 'default',
    'snid' => 1,
  ]);
  $result = $this
    ->runSensor('simplenews_pending');
  $this
    ->assertEqual($result
    ->getValue(), 1);
}