You are here

monitoring.base.test in Monitoring 7

File

test/tests/monitoring.base.test
View source
<?php

/**
 * @file
 * Contains \MonitoringTestBase.
 */

/**
 * Abstract base class for all monitoring tests.
 */
abstract class MonitoringTestBase extends DrupalWebTestCase {

  /**
   * Use testing profile to speed up tests.
   *
   * @var string
   */
  protected $profile = 'testing';

  /**
   * Sensor manager.
   *
   * @var \Drupal\monitoring\Sensor\SensorManager
   */
  protected $sensorManager;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    $modules = func_get_args();
    if (isset($modules[0]) && is_array($modules[0])) {
      $modules = $modules[0];
    }
    $modules = array_merge(array(
      'monitoring',
      'monitoring_test',
    ), $modules);
    parent::setUp($modules);
    $this->sensorManager = monitoring_sensor_manager();
    require_once drupal_get_path('module', 'monitoring') . '/monitoring.setup.inc';
  }

  /**
   * Executes a sensor and returns the result.
   *
   * @param string $sensor_name
   *   Name of the sensor to execute.
   *
   * @return \Drupal\monitoring\Result\SensorResultInterface
   *   The sensor result.
   */
  protected function runSensor($sensor_name) {

    // Make sure the sensor is enabled.
    $this->sensorManager
      ->enableSensor($sensor_name);
    return monitoring_sensor_run($sensor_name, TRUE);
  }

}

Classes

Namesort descending Description
MonitoringTestBase Abstract base class for all monitoring tests.