public function ManageFieldsFunctionalTest::manageFieldsPage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::manageFieldsPage()
Tests the manage fields page.
Parameters
string $type: (optional) The name of a content type.
1 call to ManageFieldsFunctionalTest::manageFieldsPage()
- ManageFieldsFunctionalTest::testCRUDFields in core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php - Runs the field CRUD tests.
File
- core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php, line 164
Class
- ManageFieldsFunctionalTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\FunctionalCode
public function manageFieldsPage($type = '') {
$type = empty($type) ? $this->contentType : $type;
$this
->drupalGet('admin/structure/types/manage/' . $type . '/fields');
// Check all table columns.
$table_headers = [
t('Label'),
t('Machine name'),
t('Field type'),
t('Operations'),
];
foreach ($table_headers as $table_header) {
// We check that the label appear in the table headings.
$this
->assertSession()
->responseContains($table_header . '</th>');
}
// Test the "Add field" action link.
$this
->assertSession()
->linkExists('Add field');
// Assert entity operations for all fields.
$number_of_links = 3;
$number_of_links_found = 0;
$operation_links = $this
->xpath('//ul[@class = "dropbutton"]/li/a');
$url = base_path() . "admin/structure/types/manage/{$type}/fields/node.{$type}.body";
foreach ($operation_links as $link) {
switch ($link
->getAttribute('title')) {
case 'Edit field settings.':
$this
->assertSame($url, $link
->getAttribute('href'));
$number_of_links_found++;
break;
case 'Edit storage settings.':
$this
->assertSame("{$url}/storage", $link
->getAttribute('href'));
$number_of_links_found++;
break;
case 'Delete field.':
$this
->assertSame("{$url}/delete", $link
->getAttribute('href'));
$number_of_links_found++;
break;
}
}
$this
->assertEquals($number_of_links, $number_of_links_found);
}