protected function MonitoringUITest::doTestOuterThresholdSettings in Monitoring 8
Tests outer threshold settings UI and validation.
1 call to MonitoringUITest::doTestOuterThresholdSettings()
- MonitoringUITest::testSensorSettingsUI in tests/
src/ Functional/ MonitoringUITest.php - Test the sensor settings UI.
File
- tests/
src/ Functional/ MonitoringUITest.php, line 948
Class
- MonitoringUITest
- Tests for the Monitoring UI.
Namespace
Drupal\Tests\monitoring\FunctionalCode
protected function doTestOuterThresholdSettings() {
// 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(new FormattableMarkup('Sensor @label saved.', array(
'@label' => 'Test sensor outer',
)));
$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(new FormattableMarkup('Sensor @label saved.', array(
'@label' => 'Test sensor outer',
)));
$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.');
}