You are here

protected function MonitoringMailKernelTest::setUp in Monitoring 8

Overrides MonitoringUnitTestBase::setUp

File

modules/monitoring_mail/tests/src/Kernel/MonitoringMailKernelTest.php, line 33

Class

MonitoringMailKernelTest
Kernel tests for the mail pieces of monitoring.

Namespace

Drupal\Tests\monitoring_mail\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installSchema('dblog', [
    'watchdog',
  ]);
  $this
    ->installConfig([
    'system',
    'monitoring_mail',
  ]);
  $this
    ->config('system.site')
    ->set('name', 'Example')
    ->save();
  \Drupal::moduleHandler()
    ->loadAllIncludes('install');
  monitoring_install();

  // Set the site mail.
  \Drupal::configFactory()
    ->getEditable('system.site')
    ->set('mail', 'site_mail@example.com')
    ->save();

  // Allow running all enabled sensors.
  \Drupal::configFactory()
    ->getEditable('monitoring.settings')
    ->set('cron_run_sensors', TRUE)
    ->save();

  // Set a valid email address for this test.
  \Drupal::configFactory()
    ->getEditable('monitoring_mail.settings')
    ->set('mail', 'mail@example.com')
    ->save();
}