function ManageFieldsTest::testAllowedValuesFormValidation

Same name in other branches
  1. 10 core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest::testAllowedValuesFormValidation()

Tests the form validation for allowed values field.

File

core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php, line 339

Class

ManageFieldsTest
Tests the Field UI "Manage Fields" screens.

Namespace

Drupal\Tests\field_ui\FunctionalJavascript

Code

public function testAllowedValuesFormValidation() : void {
    FieldStorageConfig::create([
        'field_name' => 'field_text',
        'entity_type' => 'node',
        'type' => 'text',
    ])->save();
    FieldConfig::create([
        'field_name' => 'field_text',
        'entity_type' => 'node',
        'bundle' => 'article',
    ])->save();
    $this->drupalGet('/admin/structure/types/manage/article/fields/node.article.field_text');
    $page = $this->getSession()
        ->getPage();
    $page->findField('edit-field-storage-subform-cardinality-number')
        ->setValue('-11');
    $this->assertSession()
        ->assertExpectedAjaxRequest(1);
    $page->findButton('Save settings')
        ->click();
    $this->assertSession()
        ->pageTextContains('Limit must be higher than or equal to 1.');
}

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