SimplenewsMonitoringTest.php in Simplenews 8.2
File
tests/src/Kernel/SimplenewsMonitoringTest.php
View source
<?php
namespace Drupal\Tests\simplenews\Kernel;
use Drupal\KernelTests\KernelTestBase;
class SimplenewsMonitoringTest extends KernelTestBase {
public static $modules = [
'node',
'system',
'views',
'user',
'field',
'text',
'simplenews',
'monitoring',
'monitoring_test',
];
public function testSensors() {
$this
->installConfig([
'system',
]);
$this
->installConfig([
'node',
]);
$this
->installConfig([
'simplenews',
]);
$this
->installEntitySchema('monitoring_sensor_result');
$this
->installSchema('simplenews', 'simplenews_mail_spool');
$result = $this
->runSensor('simplenews_pending');
$this
->assertEqual($result
->getValue(), 0);
\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);
}
protected function runSensor($sensor_name) {
monitoring_sensor_manager()
->enableSensor($sensor_name);
return monitoring_sensor_run($sensor_name, TRUE, TRUE);
}
}