You are here

public function MonitoringUITest::testSensorSettingsUI in Monitoring 8

Test the sensor settings UI.

File

tests/src/Functional/MonitoringUITest.php, line 52

Class

MonitoringUITest
Tests for the Monitoring UI.

Namespace

Drupal\Tests\monitoring\Functional

Code

public function testSensorSettingsUI() {
  $account = $this
    ->drupalCreateUser(array(
    'administer monitoring',
  ));
  $this
    ->drupalLogin($account);

  // The separate threshold settings tests have been split into separate
  // methods for better separation.
  $this
    ->doTestExceedsThresholdSettings();
  $this
    ->doTestFallsThresholdSettings();
  $this
    ->doTestInnerThresholdSettings();
  $this
    ->doTestOuterThresholdSettings();

  // Test that trying to access the sensors settings page of a non-existing
  // sensor results in a page not found response.
  $this
    ->drupalGet('admin/config/system/monitoring/sensors/non_existing_sensor');
  $this
    ->assertResponse(404);

  // Tests the fields 'Sensor Plugin' & 'Entity Type' appear.
  $this
    ->drupalGet('admin/config/system/monitoring/sensors/user_new');
  $this
    ->assertOptionSelected('edit-settings-entity-type', 'user');
  $this
    ->assertText('Sensor Plugin');
  $this
    ->assertText('Entity Aggregator');

  // Tests adding a condition to the log out sensor.
  $this
    ->drupalGet('admin/config/system/monitoring/sensors/user_session_logouts');
  $edit = array(
    'conditions[2][field]' => 'severity',
    'conditions[2][value]' => 5,
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->drupalGet('admin/config/system/monitoring/sensors/user_session_logouts');
  $this
    ->assertFieldByName('conditions[2][field]', 'severity');
  $this
    ->assertFieldByName('conditions[2][value]', 5);
}