You are here

monitoring_test.module in Monitoring 7

Monitoring test bootstrap file.

File

test/monitoring_test.module
View source
<?php

/**
 * @file
 * Monitoring test bootstrap file.
 */

/**
 * Implements of hook_ctools_plugin_api().
 */
function monitoring_test_ctools_plugin_api($module, $api) {
  if ($module == 'services' && $api == 'services') {
    return array(
      'version' => 3,
      'file' => 'monitoring_test.default_services.inc',
      'path' => drupal_get_path('module', 'monitoring_test'),
    );
  }
}

/**
 * Implements hook_cron_queue_info().
 */
function monitoring_test_cron_queue_info() {
  $queues['monitoring_test'] = array(
    'worker callback' => 'monitoring_test_queue_worker',
    'time' => 60,
  );
  return $queues;
}

/**
 * Dummy worker callback for test queue.
 */
function monitoring_test_queue_worker() {
}

/**
 * Implements monitoring_MODULE_monitoring_sensor_info().
 *
 * @see \MonitoringApiTest::testAPI()
 */
function monitoring_monitoring_test_monitoring_sensor_info() {
  $info = array(
    'test_sensor_integration' => array(
      'label' => 'Test from integration hook',
      'description' => 'To test correct sensor info hook implementation precedence.',
      'sensor_class' => 'Drupal\\monitoring_test\\Sensor\\Sensors\\TestSensor',
      'settings' => array(
        'result_logging' => FALSE,
        'category' => 'Test',
      ),
    ),
    'watchdog_aggregate_test' => array(
      'label' => 'Watchdog aggregate test',
      'description' => 'Test sensor for watchdog aggregate.',
      'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorDatabaseAggregator',
      'settings' => array(
        'result_logging' => FALSE,
        'category' => 'Test',
        'thresholds' => array(
          'warning' => 1,
          'critical' => 2,
        ),
        'table' => 'watchdog',
      ),
    ),
    'db_aggregate_test' => array(
      'label' => 'DB Aggregate test',
      'description' => 'Tests the generic DB aggregate sensor.',
      'sensor_class' => 'Drupal\\monitoring\\Sensor\\Sensors\\SensorDatabaseAggregator',
      'value_label' => 'Druplicons',
      'result_logging' => TRUE,
      'settings' => array(
        'category' => 'Test',
        'caching_time' => 3600,
        'table' => 'node',
        'conditions' => array(
          'test' => array(
            'field' => 'promote',
            'value' => '1',
          ),
        ),
        'time_interval_field' => 'created',
        'time_interval_value' => 24 * 60 * 60,
        'thresholds' => array(
          'type' => 'falls',
          'warning' => 2,
          'critical' => 1,
        ),
      ),
    ),
    'test_sensor' => array(
      'label' => 'Test sensor',
      'description' => 'Test sensor status',
      'sensor_class' => 'Drupal\\monitoring_test\\Sensor\\Sensors\\TestSensor',
      'settings' => array(
        'result_logging' => TRUE,
        'category' => 'Test',
        'caching_time' => 3600,
      ),
    ),
    'test_sensor_inner' => array(
      'label' => 'Test sensor inner',
      'description' => 'Test sensor that sets inner error intervals',
      'sensor_class' => 'Drupal\\monitoring_test\\Sensor\\Sensors\\TestSensor',
      'settings' => array(
        'result_logging' => TRUE,
        'category' => 'Test',
        'thresholds' => array(
          'type' => 'inner_interval',
          'warning_low' => 1,
          'critical_low' => 4,
          'critical_high' => 6,
          'warning_high' => 9,
        ),
      ),
    ),
    'test_sensor_outer' => array(
      'label' => 'Test sensor outer',
      'description' => 'Test sensor that sets outer error intervals',
      'sensor_class' => 'Drupal\\monitoring_test\\Sensor\\Sensors\\TestSensor',
      'settings' => array(
        'result_logging' => TRUE,
        'category' => 'Test',
        'thresholds' => array(
          'type' => 'outer_interval',
          'critical_low' => 60,
          'warning_low' => 70,
          'warning_high' => 80,
          'critical_high' => 90,
        ),
      ),
    ),
    'test_sensor_exceeds' => array(
      'label' => 'Test sensor exceeds',
      'description' => 'Test sensor that sets error interval above give value',
      'sensor_class' => 'Drupal\\monitoring_test\\Sensor\\Sensors\\TestSensor',
      'settings' => array(
        'result_logging' => TRUE,
        'category' => 'Test',
        'thresholds' => array(
          'type' => 'exceeds',
          'warning' => 5,
          'critical' => 10,
        ),
      ),
    ),
    'test_sensor_falls' => array(
      'label' => 'Test sensor falls',
      'description' => 'Test sensor that sets error interval below give value',
      'sensor_class' => 'Drupal\\monitoring_test\\Sensor\\Sensors\\TestSensor',
      'settings' => array(
        'result_logging' => TRUE,
        'category' => 'Test',
        'thresholds' => array(
          'type' => 'falls',
          'warning' => 10,
          'critical' => 5,
        ),
      ),
    ),
    'test_sensor_cat_watchdog' => array(
      'label' => 'Test sensor category Watchdog',
      'description' => 'Test sensor with Watchdog category to test the watchdog logging',
      'sensor_class' => 'Drupal\\monitoring_test\\Sensor\\Sensors\\TestSensor',
      'settings' => array(
        'category' => 'Watchdog',
      ),
    ),
  );

  // In case we have testing_sensor_info data we add it as a new sensor.
  // @see \MonitoringApiTest::testAPI()
  $testing_sensor_info = variable_get('monitoring_test_sensor_info');
  if (!empty($testing_sensor_info)) {
    $info['test_sensor_info'] = $testing_sensor_info;
  }
  return $info;
}

/**
 * Implements hook_commerce_currency_info_alter().
 */
function monitoring_test_commerce_currency_info_alter(&$currencies, $langcode) {

  // Alter CHF currency to use a ' as thousands separator, to verify correct
  // encoding of the status message.
  $currencies['CHF']['decimal_separator'] = '.';
  $currencies['CHF']['thousands_separator'] = '\'';
  $currencies['CHF']['code_placement'] = 'before';
}