You are here

public function RangeFormatterUiTestBase::testFormatterUi in Range 8

Tests the formatter UI.

5 calls to RangeFormatterUiTestBase::testFormatterUi()
RangeDecimalFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeDecimalFormatterUiTest.php
Tests the formatter UI.
RangeDecimalSprintfFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeDecimalSprintfFormatterUiTest.php
Tests the formatter UI.
RangeIntegerFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeIntegerFormatterUiTest.php
Tests the formatter UI.
RangeIntegerSprintfFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeIntegerSprintfFormatterUiTest.php
Tests the formatter UI.
RangeUnformattedFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeUnformattedFormatterUiTest.php
Tests the formatter UI.
5 methods override RangeFormatterUiTestBase::testFormatterUi()
RangeDecimalFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeDecimalFormatterUiTest.php
Tests the formatter UI.
RangeDecimalSprintfFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeDecimalSprintfFormatterUiTest.php
Tests the formatter UI.
RangeIntegerFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeIntegerFormatterUiTest.php
Tests the formatter UI.
RangeIntegerSprintfFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeIntegerSprintfFormatterUiTest.php
Tests the formatter UI.
RangeUnformattedFormatterUiTest::testFormatterUi in tests/src/Functional/Formatter/RangeUnformattedFormatterUiTest.php
Tests the formatter UI.

File

tests/src/Functional/Formatter/RangeFormatterUiTestBase.php, line 76

Class

RangeFormatterUiTestBase
Base class for testing formatter UI.

Namespace

Drupal\Tests\range\Functional\Formatter

Code

public function testFormatterUi() {
  $this
    ->drupalGet('entity_test/structure/entity_test/display');

  // Enable Default formatter.
  $edit = [
    "fields[{$this->fieldName}][parent]" => 'content',
    "fields[{$this->fieldName}][region]" => 'content',
    "fields[{$this->fieldName}][type]" => $this->formatterType,
  ];
  $this
    ->submitForm($edit, 'Save');

  // Ensure that default summary is correct.
  $this->session
    ->pageTextContains('Equivalent values will be combined into a single value.');
  $this->session
    ->pageTextNotContains('Display with FIELD value prefix and suffix');
  $this->session
    ->pageTextNotContains('Display with FROM value prefix and suffix.');
  $this->session
    ->pageTextNotContains('Display with TO value prefix and suffix.');
  $this->session
    ->pageTextNotContains('Display with COMBINED value prefix and suffix.');

  // Go to formatter settings form.
  $this
    ->submitForm([], $this->fieldName . '_settings_edit');
  $this->session
    ->checkboxChecked('Combine equivalent values');
  $this->session
    ->checkboxNotChecked('Display FIELD value prefix and suffix');
  $this->session
    ->checkboxNotChecked('Display FROM value prefix and suffix');
  $this->session
    ->checkboxNotChecked('Display TO value prefix and suffix');
  $this->session
    ->checkboxNotChecked('Display COMBINED value prefix and suffix');

  // Update formatter settings.
  $edit = [
    "fields[{$this->fieldName}][settings_edit_form][settings][range_combine]" => FALSE,
    "fields[{$this->fieldName}][settings_edit_form][settings][field_prefix_suffix]" => TRUE,
    "fields[{$this->fieldName}][settings_edit_form][settings][from_prefix_suffix]" => TRUE,
    "fields[{$this->fieldName}][settings_edit_form][settings][to_prefix_suffix]" => FALSE,
    "fields[{$this->fieldName}][settings_edit_form][settings][combined_prefix_suffix]" => FALSE,
  ];
  $this
    ->submitForm($edit, 'Update');

  // Ensure that summary is correct.
  $this->session
    ->pageTextNotContains('Equivalent values will be combined into a single value.');
  $this->session
    ->pageTextContains('Display with FIELD value prefix and suffix');
  $this->session
    ->pageTextContains('Display with FROM value prefix and suffix.');
  $this->session
    ->pageTextNotContains('Display with TO value prefix and suffix.');
  $this->session
    ->pageTextNotContains('Display with COMBINED value prefix and suffix.');

  // Go to formatter settings form.
  $this
    ->submitForm([], $this->fieldName . '_settings_edit');

  // Ensure that form displays correct set of fields.
  $this->session
    ->checkboxNotChecked('Combine equivalent values');
  $this->session
    ->checkboxChecked('Display FIELD value prefix and suffix');
  $this->session
    ->checkboxChecked('Display FROM value prefix and suffix');
  $this->session
    ->checkboxNotChecked('Display TO value prefix and suffix');
  $this->session
    ->checkboxNotChecked('Display COMBINED value prefix and suffix');

  // Update formatter settings.
  $edit = [
    "fields[{$this->fieldName}][settings_edit_form][settings][range_combine]" => TRUE,
    "fields[{$this->fieldName}][settings_edit_form][settings][field_prefix_suffix]" => FALSE,
    "fields[{$this->fieldName}][settings_edit_form][settings][from_prefix_suffix]" => FALSE,
    "fields[{$this->fieldName}][settings_edit_form][settings][to_prefix_suffix]" => TRUE,
    "fields[{$this->fieldName}][settings_edit_form][settings][combined_prefix_suffix]" => TRUE,
  ];
  $this
    ->submitForm($edit, 'Update');

  // Ensure that summary is correct.
  $this->session
    ->pageTextContains('Equivalent values will be combined into a single value.');
  $this->session
    ->pageTextNotContains('Display with FIELD value prefix and suffix.');
  $this->session
    ->pageTextNotContains('Display with FROM value prefix and suffix.');
  $this->session
    ->pageTextContains('Display with TO value prefix and suffix.');
  $this->session
    ->pageTextContains('Display with COMBINED value prefix and suffix.');

  // Go to formatter settings form.
  $this
    ->submitForm([], $this->fieldName . '_settings_edit');

  // Ensure that form displays correct set of fields.
  $this->session
    ->checkboxChecked('Combine equivalent values');
  $this->session
    ->checkboxNotChecked('Display FIELD value prefix and suffix');
  $this->session
    ->checkboxNotChecked('Display FROM value prefix and suffix');
  $this->session
    ->checkboxChecked('Display TO value prefix and suffix');
  $this->session
    ->checkboxChecked('Display COMBINED value prefix and suffix');

  // Update formatter settings.
  $edit = [
    "fields[{$this->fieldName}][settings_edit_form][settings][range_combine]" => FALSE,
  ];
  $this
    ->submitForm($edit, 'Update');

  // Ensure that summary is correct.
  $this->session
    ->pageTextNotContains('Equivalent values will be combined into a single value.');
  $this->session
    ->pageTextNotContains('Display with COMBINED value prefix and suffix.');
}