function ManageFieldsTest::testFieldTypeOrder
Same name and namespace in other branches
- 10 core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest::testFieldTypeOrder()
- main core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest::testFieldTypeOrder()
Tests the order in which the field types appear in the form.
File
-
core/
modules/ field_ui/ tests/ src/ FunctionalJavascript/ ManageFieldsTest.php, line 299
Class
- ManageFieldsTest
- Tests the Field UI "Manage Fields" screens.
Namespace
Drupal\Tests\field_ui\FunctionalJavascriptCode
public function testFieldTypeOrder() : void {
$field_type_categories = [
'Selection list',
'Number',
];
foreach ($field_type_categories as $field_type_category) {
$page = $this->getSession()
->getPage();
$assert_session = $this->assertSession();
$this->drupalGet('admin/structure/types/manage/article/fields/add-field');
// Select the group card.
$this->clickLink($field_type_category);
$this->assertSession()
->assertWaitOnAjaxRequest();
$field_types = $page->findAll('css', '.subfield-option .option');
$field_type_labels = [];
foreach ($field_types as $field_type) {
$field_type_labels[] = $field_type->getText();
}
$expected_field_types = match ($field_type_category) { 'Selection list' => [
'Text',
'Integer',
],
'Number' => [
'Integer',
'Decimal',
],
};
// Assert that the field type options are displayed as per their weights.
$this->assertSame($expected_field_types, $field_type_labels);
// Return to the first step of the form.
$assert_session->buttonExists('Change field type')
->press();
$assert_session->assertWaitOnAjaxRequest();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.