function OptionsFieldUITest::assertAllowedValuesInput

Same name in other branches
  1. 8.9.x core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::assertAllowedValuesInput()
  2. 10 core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::assertAllowedValuesInput()
  3. 11.x core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::assertAllowedValuesInput()

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

@internal

Parameters

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

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

string $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 323

Class

OptionsFieldUITest
Tests the Options field UI functionality.

Namespace

Drupal\Tests\options\Functional

Code

public function assertAllowedValuesInput(string $input_string, $result, string $message) : void {
    $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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.