You are here

protected function MonitoringUITest::checkOuterThresholdSettings in Monitoring 7

Tests outer threshold settings UI and validation.

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

File

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

Class

MonitoringUITest
Tests for the Monitoring UI.

Code

protected function checkOuterThresholdSettings() {

  // Test with valid values.
  $thresholds = array(
    'critical_low' => 5,
    'warning_low' => 6,
    'critical_high' => 15,
    'warning_high' => 14,
  );
  $this
    ->submitThresholdSettings('test_sensor_outer', $thresholds);
  $this
    ->assertText(t('Sensor settings saved.'));
  $this
    ->assertThresholdSettingsUIDefaults('test_sensor_outer', $thresholds);

  // Make sure that it is possible to save empty outer thresholds.
  $thresholds = array(
    'critical_low' => '',
    'warning_low' => '',
    'critical_high' => '',
    'warning_high' => '',
  );
  $this
    ->submitThresholdSettings('test_sensor_outer', $thresholds);
  $this
    ->assertText(t('Sensor settings saved.'));
  $this
    ->assertThresholdSettingsUIDefaults('test_sensor_outer', $thresholds);

  // Test validation.
  $thresholds = array(
    'critical_low' => 5,
    'warning_low' => 15,
    'critical_high' => 10,
    'warning_high' => 20,
  );
  $this
    ->submitThresholdSettings('test_sensor_outer', $thresholds);
  $this
    ->assertText('Warning high must be lower than critical high or empty.');
  $thresholds = array(
    'critical_low' => 5,
    'warning_low' => 5,
    'critical_high' => 5,
    'warning_high' => 5,
  );
  $this
    ->submitThresholdSettings('test_sensor_outer', $thresholds);
  $this
    ->assertText('Warning low must be lower than warning high or empty.');
  $thresholds = array(
    'critical_low' => 'alphanumeric',
    'warning_low' => 'alphanumeric',
    'critical_high' => 'alphanumeric',
    'warning_high' => 'alphanumeric',
  );
  $this
    ->submitThresholdSettings('test_sensor_outer', $thresholds);
  $this
    ->assertText('Warning low must be a number.');
  $this
    ->assertText('Warning high must be a number.');
  $this
    ->assertText('Critical low must be a number.');
  $this
    ->assertText('Critical high must be a number.');
  $thresholds = array(
    'critical_low' => 45,
    'warning_low' => 35,
    'critical_high' => 45,
    'warning_high' => 35,
  );
  $this
    ->submitThresholdSettings('test_sensor_outer', $thresholds);
  $this
    ->assertText('Warning low must be lower than warning high or empty.');
  $thresholds = array(
    'critical_low' => 50,
    'warning_low' => 95,
    'critical_high' => 55,
    'warning_high' => 100,
  );
  $this
    ->submitThresholdSettings('test_sensor_outer', $thresholds);
  $this
    ->assertText('Warning high must be lower than critical high or empty.');
}