You are here

public function MultigraphWebTest::doTestMultigraphAdd in Monitoring 8

Tests multigraph creation.

1 call to MultigraphWebTest::doTestMultigraphAdd()
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 61
Contains \Drupal\monitoring_multigraph\Tests\MultigraphWebTest

Class

MultigraphWebTest
Tests the Multigraph forms (add/edit/delete).

Namespace

Drupal\Tests\monitoring_multigraph\Functional

Code

public function doTestMultigraphAdd() {

  // Add a few sensors.
  $values = [
    'label' => $this
      ->randomString(),
    'id' => 'multigraph_123',
    'description' => $this
      ->randomString(),
    'sensor_add_select' => 'dblog_404',
  ];
  $this
    ->drupalPostForm('admin/config/system/monitoring/multigraphs/add', $values, t('Add sensor'));
  $this
    ->assertText(t('Sensor "Page not found errors" added. You have unsaved changes.'));
  $this
    ->drupalPostForm(NULL, [
    'sensor_add_select' => 'user_failed_logins',
  ], t('Add sensor'));
  $this
    ->assertText(t('Sensor "Failed user logins" added. You have unsaved changes.'));
  $this
    ->drupalPostForm(NULL, [
    'sensor_add_select' => 'user_successful_logins',
  ], t('Add sensor'));
  $this
    ->assertText(t('Sensor "Successful user logins" added. You have unsaved changes.'));

  // And last but not least, change all sensor label values and save form.
  $this
    ->drupalPostForm(NULL, [
    'sensors[dblog_404][label]' => 'Page not found errors (test)',
    'sensors[user_failed_logins][label]' => 'Failed user logins (test)',
    'sensors[user_successful_logins][label]' => 'Successful user logins (test)',
  ], t('Save'));
  $this
    ->assertText(t('Multigraph settings saved.'));
  $this
    ->assertText('Page not found errors (test), Failed user logins (test), Successful user logins (test)');
}