You are here

public function RangeUpdatePathTest::testNoRegressionsAfterUpdates in Range 8

Tests that base features are not broken.

This test does not check everything. It is more a smoke test. Note that configuration forms are not being submitted so nothing is being changed so each feature can be tested with as little interference as possible.

For the future it worth to test each feature in the own test method.

@link https://www.drupal.org/node/3150297

File

tests/src/Functional/Update/RangeUpdatePathTest.php, line 84

Class

RangeUpdatePathTest
Tests range module update path.

Namespace

Drupal\Tests\range\Functional\Update

Code

public function testNoRegressionsAfterUpdates() {

  // Run the updates.
  $this
    ->runUpdates();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer node display',
    'administer node form display',
    'create page content',
  ]));

  // Ensure no regressions while editing content.
  $range_fields = [
    'field_decimal',
    'field_float',
    'field_integer',
  ];
  $this
    ->drupalGet('node/add/page');
  foreach ($range_fields as $field_name) {
    $edit = [
      $field_name . '[0][from]' => 0,
      $field_name . '[0][to]' => 5,
    ];
    $this
      ->submitForm($edit, 'Save');
  }

  // Ensure no regressions while editing range fields configuration.
  foreach ($range_fields as $field_name) {
    $this
      ->drupalGet('admin/structure/types/manage/page/fields');
    $this
      ->drupalGet('admin/structure/types/manage/page/fields/node.page.' . $field_name);
    $this
      ->drupalGet('admin/structure/types/manage/page/fields/node.page.' . $field_name);
    $this
      ->drupalGet('admin/structure/types/manage/page/fields/node.page.' . $field_name . '/storage');
  }

  // Ensure no regressions while editing range fields display.
  $view_modes = [
    'default_formatter',
    'unformatted_formatter',
  ];
  foreach ($view_modes as $view_mode) {
    $this
      ->drupalGet('admin/structure/types/manage/page/display/' . $view_mode);
    foreach ($range_fields as $field_name) {
      $this
        ->submitForm([], $field_name . '_settings_edit');
      $this
        ->submitForm([], 'Cancel');
    }
  }

  // Ensure no regressions while editing range fields form display.
  $form_modes = [
    'default',
  ];
  foreach ($form_modes as $form_mode) {
    $this
      ->drupalGet('admin/structure/types/manage/page/form-display/' . $form_mode);
    foreach ($range_fields as $field_name) {
      $this
        ->submitForm([], $field_name . '_settings_edit');
      $this
        ->submitForm([], 'Cancel');
    }
  }
}