public function MonitoringUITest::testSensorDisappearedSensorsUI in Monitoring 8
UI Tests for disappearing sensors.
We provide a separate test method for the DisappearedSensorsSensorPlugin as we need to install and uninstall additional modules.
See also
\Drupal\monitoring\Plugin\monitoring\SensorPlugin\DisappearedSensorsSensorPlugin
File
- tests/
src/ Functional/ MonitoringUITest.php, line 595
Class
- MonitoringUITest
- Tests for the Monitoring UI.
Namespace
Drupal\Tests\monitoring\FunctionalCode
public function testSensorDisappearedSensorsUI() {
$account = $this
->drupalCreateUser(array(
'administer monitoring',
));
$this
->drupalLogin($account);
// Install comment module and the comment_new sensor.
$this
->installModules(array(
'comment',
));
monitoring_sensor_manager()
->enableSensor('comment_new');
// We should have the message that no sensors are missing.
$this
->drupalGet('admin/config/system/monitoring/sensors/monitoring_disappeared_sensors');
$this
->assertNoText(t('This action will clear the missing sensors and the critical sensor status will go away.'));
// Disable sensor and the ininstall comment module. This is the correct
// procedure and therefore there should be no missing sensors.
monitoring_sensor_manager()
->disableSensor('comment_new');
$this
->drupalGet('admin/config/system/monitoring/sensors/monitoring_disappeared_sensors');
$this
->assertNoText(t('This action will clear the missing sensors and the critical sensor status will go away.'));
// Install comment module and the comment_new sensor.
$this
->installModules(array(
'comment',
));
monitoring_sensor_manager()
->enableSensor('comment_new');
// Now uninstall the comment module to have the comment_new sensor disappear.
$this
->uninstallModules(array(
'comment',
));
// Run the monitoring_disappeared_sensors sensor to get the status message
// that should be found in the settings form.
$this
->drupalGet('admin/config/system/monitoring/sensors/monitoring_disappeared_sensors');
$this
->assertText('Missing sensor comment_new');
// Now reset the sensor list - we should get the "no missing sensors"
// message.
$this
->drupalPostForm(NULL, array(), t('Clear missing sensors'));
$this
->assertText(t('All missing sensors have been cleared.'));
$this
->drupalGet('admin/config/system/monitoring/sensors/monitoring_disappeared_sensors');
$this
->assertNoText('Missing sensor comment_new');
}