function NodeTypeTest::testNodeTypeOperations
Same name in other branches
- 9 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeOperations()
- 10 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeOperations()
Tests operations from Field UI and User modules for content types.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeTypeTest.php, line 234
Class
- NodeTypeTest
- Ensures that node type functions work correctly.
Namespace
Drupal\Tests\node\FunctionalCode
public function testNodeTypeOperations() : void {
// Create an admin user who can only manage node fields.
$admin_user_1 = $this->drupalCreateUser([
'administer content types',
'administer node fields',
'administer permissions',
]);
$this->drupalLogin($admin_user_1);
// Test that the user only sees the actions available to them.
$this->drupalGet('admin/structure/types');
$this->assertSession()
->linkByHrefExists('admin/structure/types/manage/article/fields');
$this->assertSession()
->linkByHrefExists('admin/structure/types/manage/article/permissions');
$this->assertSession()
->linkByHrefNotExists('admin/structure/types/manage/article/display');
// Create another admin user who can manage node fields display.
$admin_user_2 = $this->drupalCreateUser([
'administer content types',
'administer node display',
]);
$this->drupalLogin($admin_user_2);
// Test that the user only sees the actions available to them.
$this->drupalGet('admin/structure/types');
$this->assertSession()
->linkByHrefNotExists('admin/structure/types/manage/article/fields');
$this->assertSession()
->linkByHrefNotExists('admin/structure/types/manage/article/permissions');
$this->assertSession()
->linkByHrefExists('admin/structure/types/manage/article/display');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.