You are here

protected function MonitoringUITest::checkExceedsThresholdSettings in Monitoring 7

Tests exceeds threshold settings UI and validation.

1 call to MonitoringUITest::checkExceedsThresholdSettings()
MonitoringUITest::testSensorSettingsUI in test/tests/monitoring.ui.test
Test the sensor settings UI.

File

test/tests/monitoring.ui.test, line 300
Contains \MonitoringUITest.

Class

MonitoringUITest
Tests for the Monitoring UI.

Code

protected function checkExceedsThresholdSettings() {

  // Test with valid values.
  $thresholds = array(
    'critical' => 11,
    'warning' => 6,
  );
  $this
    ->submitThresholdSettings('test_sensor_exceeds', $thresholds);
  $this
    ->assertText(t('Sensor settings saved.'));
  $this
    ->assertThresholdSettingsUIDefaults('test_sensor_exceeds', $thresholds);

  // Make sure that it is possible to save empty thresholds.
  $thresholds = array(
    'critical' => '',
    'warning' => '',
  );
  $this
    ->submitThresholdSettings('test_sensor_exceeds', $thresholds);
  $this
    ->assertText(t('Sensor settings saved.'));
  $this
    ->assertThresholdSettingsUIDefaults('test_sensor_exceeds', $thresholds);
  $this->sensorManager
    ->resetCache();
  SensorRunner::resetCache();
  $sensor_result = $this
    ->runSensor('test_sensor_exceeds');
  $this
    ->assertTrue($sensor_result
    ->isOk());

  // Test validation.
  $thresholds = array(
    'critical' => 5,
    'warning' => 10,
  );
  $this
    ->submitThresholdSettings('test_sensor_exceeds', $thresholds);
  $this
    ->assertText('Warning must be lower than critical or empty.');
  $thresholds = array(
    'critical' => 5,
    'warning' => 5,
  );
  $this
    ->submitThresholdSettings('test_sensor_exceeds', $thresholds);
  $this
    ->assertText('Warning must be lower than critical or empty.');
  $thresholds = array(
    'critical' => 'alphanumeric',
    'warning' => 'alphanumeric',
  );
  $this
    ->submitThresholdSettings('test_sensor_exceeds', $thresholds);
  $this
    ->assertText('Warning must be a number.');
  $this
    ->assertText('Critical must be a number.');
  return $thresholds;
}