function OptionsFieldUITest::assertAllowedValuesInput

Same name in other branches
  1. 9 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.

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 319

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->drupalPostForm($this->adminPath, $edit, t('Save field settings'));
    $this->assertNoRaw('<', 'The page does not have double escaped HTML tags.');
    if (is_string($result)) {
        $this->assertText($result, $message);
    }
    else {
        $field_storage = FieldStorageConfig::loadByName('node', $this->fieldName);
        $this->assertIdentical($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.