function ManageFieldsLifecycleTest::manageFieldsPage
Same name in other branches
- 10 core/modules/field_ui/tests/src/Functional/ManageFieldsLifecycleTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsLifecycleTest::manageFieldsPage()
Tests the manage fields page.
Parameters
string $type: (optional) The name of a content type.
1 call to ManageFieldsLifecycleTest::manageFieldsPage()
- ManageFieldsLifecycleTest::testCRUDFields in core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsLifecycleTest.php - Runs the field CRUD tests.
File
-
core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsLifecycleTest.php, line 41
Class
- ManageFieldsLifecycleTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\FunctionalCode
protected function manageFieldsPage($type = '') : void {
$type = empty($type) ? $this->contentType : $type;
$this->drupalGet('admin/structure/types/manage/' . $type . '/fields');
// Check all table columns.
$table_headers = [
'Label',
'Machine name',
'Field type',
'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 "Create a new field" action link.
$this->assertSession()
->linkExists('Create a new field');
// Assert entity operations for all fields.
$number_of_links = 2;
$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 'Delete field.':
$this->assertSame("{$url}/delete", $link->getAttribute('href'));
$number_of_links_found++;
break;
}
}
$this->assertEquals($number_of_links, $number_of_links_found);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.