function OptionsFieldUITest::assertAllowedValuesInput

Same name and namespace in other branches
  1. 9 core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::assertAllowedValuesInput()
  2. 8.9.x 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 an input array for the 'allowed values' form element.

@internal

Parameters

array $input: The input array.

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

string $message: Message to display.

3 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.

File

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

Class

OptionsFieldUITest
Tests the Options field UI functionality.

Namespace

Drupal\Tests\options\Functional

Code

public function assertAllowedValuesInput(array $input, $result, string $message) : void {
  $this->drupalGet($this->adminPath);
  $page = $this->getSession()
    ->getPage();
  $add_button = $page->findButton('Add another item');
  $add_button->click();
  $add_button->click();
  $this->submitForm($input, 'Save');
  // 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.