You are here

public function OptionsFieldUITest::assertAllowedValuesInput in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::assertAllowedValuesInput()

Tests a string input for the 'allowed values' form element.

Parameters

$input_string: The input string, in the pipe-linefeed format expected by the form element.

$result: Either an expected resulting array in $field->getSetting('allowed_values'), or an expected error message.

$message: Message to display.

4 calls to OptionsFieldUITest::assertAllowedValuesInput()
OptionsFieldUITest::testOptionsAllowedValuesFloat in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (float) : test 'allowed values' input.
OptionsFieldUITest::testOptionsAllowedValuesInteger in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (integer) : test 'allowed values' input.
OptionsFieldUITest::testOptionsAllowedValuesText in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (text) : test 'allowed values' input.
OptionsFieldUITest::testOptionsTrimmedValuesText in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (text) : test 'trimmed values' input.

File

core/modules/options/tests/src/Functional/OptionsFieldUITest.php, line 318

Class

OptionsFieldUITest
Tests the Options field UI functionality.

Namespace

Drupal\Tests\options\Functional

Code

public function assertAllowedValuesInput($input_string, $result, $message) {
  $edit = [
    'settings[allowed_values]' => $input_string,
  ];
  $this
    ->drupalGet($this->adminPath);
  $this
    ->submitForm($edit, 'Save field settings');

  // Verify that the page does not have double escaped HTML tags.
  $this
    ->assertSession()
    ->responseNotContains('<');
  if (is_string($result)) {
    $this
      ->assertSession()
      ->pageTextContains($result);
  }
  else {
    $field_storage = FieldStorageConfig::loadByName('node', $this->fieldName);
    $this
      ->assertSame($field_storage
      ->getSetting('allowed_values'), $result, $message);
  }
}