function ManageFieldsFunctionalTest::testFieldPrefix
Same name in other branches
- 9 core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testFieldPrefix()
- 8.9.x core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testFieldPrefix()
- 11.x core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testFieldPrefix()
Tests that the 'field_prefix' setting works on Field UI.
File
-
core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php, line 362
Class
- ManageFieldsFunctionalTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\FunctionalCode
public function testFieldPrefix() : void {
// Change default field prefix.
$field_prefix = $this->randomMachineName(10);
$this->config('field_ui.settings')
->set('field_prefix', $field_prefix)
->save();
// Create a field input and label exceeding the new maxlength, which is 22.
$field_exceed_max_length_label = $this->randomString(23);
$field_exceed_max_length_input = $this->randomMachineName(23);
// Try to create the field.
$edit1 = [
'new_storage_type' => 'test_field',
];
$edit2 = [
'label' => $field_exceed_max_length_label,
'field_name' => $field_exceed_max_length_input,
];
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/add-field');
$this->submitForm($edit1, 'Continue');
$this->submitForm($edit2, 'Continue');
$this->assertSession()
->pageTextContains('Machine-readable name cannot be longer than 22 characters but is currently 23 characters long.');
// Create a valid field.
$this->fieldUIAddNewField('admin/structure/types/manage/' . $this->contentType, $this->fieldNameInput, $this->fieldLabel);
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/node.' . $this->contentType . '.' . $field_prefix . $this->fieldNameInput);
$this->assertSession()
->pageTextContains($this->fieldLabel . ' settings for ' . $this->contentType);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.