You are here

protected function MonitoringUITest::checkFallsThresholdSettings in Monitoring 7

Tests falls threshold settings UI and validation.

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

File

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

Class

MonitoringUITest
Tests for the Monitoring UI.

Code

protected function checkFallsThresholdSettings() {

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

  // Make sure that it is possible to save empty thresholds.
  $thresholds = array(
    'critical' => '',
    'warning' => '',
  );
  $this
    ->submitThresholdSettings('test_sensor_falls', $thresholds);
  $this
    ->assertText(t('Sensor settings saved.'));
  $this
    ->assertThresholdSettingsUIDefaults('test_sensor_falls', $thresholds);

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