public function MultigraphWebTest::doTestMultigraphEdit in Monitoring 8
Tests multigraph editing.
Tests all changeable input fields.
1 call to MultigraphWebTest::doTestMultigraphEdit()
- MultigraphWebTest::testMultigraphForm in modules/
multigraph/ tests/ src/ Functional/ MultigraphWebTest.php - Configures test base and executes test cases.
File
- modules/
multigraph/ tests/ src/ Functional/ MultigraphWebTest.php, line 97 - Contains \Drupal\monitoring_multigraph\Tests\MultigraphWebTest
Class
- MultigraphWebTest
- Tests the Multigraph forms (add/edit/delete).
Namespace
Drupal\Tests\monitoring_multigraph\FunctionalCode
public function doTestMultigraphEdit() {
// Go to multigraph overview and test editing pre-installed multigraph.
$this
->drupalGet('admin/config/system/monitoring/multigraphs');
// Check label, description and sensors (before editing).
$this
->assertText('Watchdog severe entries');
$this
->assertText('Watchdog entries with severity Warning or higher');
$this
->assertText('404, Alert, Critical, Emergency, Error');
// Edit.
$this
->drupalGet('admin/config/system/monitoring/multigraphs/watchdog_severe_entries');
$this
->assertText('Edit Multigraph');
// Change label, description and add a sensor.
$values = [
'label' => 'Watchdog severe entries (test)',
'description' => 'Watchdog entries with severity Warning or higher (test)',
'sensor_add_select' => 'user_successful_logins',
];
$this
->drupalPostForm(NULL, $values, t('Add sensor'));
$this
->assertText('Sensor "Successful user logins" added. You have unsaved changes.');
// Remove a sensor.
$this
->getSession()
->getPage()
->pressButton('remove_dblog_404');
// (drupalPostAjaxForm() lets us target the button precisely.)
$this
->assertText(t('Sensor "Page not found errors" removed. You have unsaved changes.'));
$this
->drupalPostForm(NULL, [], t('Save'));
// Change weights and save form.
$this
->drupalPostForm('admin/config/system/monitoring/multigraphs/watchdog_severe_entries', [
'sensors[user_successful_logins][weight]' => -2,
'sensors[dblog_event_severity_error][weight]' => -1,
'sensors[dblog_event_severity_critical][weight]' => 0,
'sensors[dblog_event_severity_emergency][weight]' => 1,
'sensors[dblog_event_severity_alert][weight]' => 2,
], t('Save'));
$this
->assertText(t('Multigraph settings saved.'));
// Go back to multigraph overview and check changed values.
$this
->drupalGet('admin/config/system/monitoring/multigraphs');
$this
->assertText('Watchdog severe entries (test)');
$this
->assertText('Watchdog entries with severity Warning or higher (test)');
$this
->assertText('Successful user logins, Error, Critical, Emergency, Alert');
}