You are here

public function NodeTypeTest::testNodeTypeFieldUiPermissions in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeFieldUiPermissions()

Tests Field UI integration for content types.

File

core/modules/node/tests/src/Functional/NodeTypeTest.php, line 231

Class

NodeTypeTest
Ensures that node type functions work correctly.

Namespace

Drupal\Tests\node\Functional

Code

public function testNodeTypeFieldUiPermissions() {

  // Create an admin user who can only manage node fields.
  $admin_user_1 = $this
    ->drupalCreateUser([
    'administer content types',
    'administer node fields',
  ]);
  $this
    ->drupalLogin($admin_user_1);

  // Test that the user only sees the actions available to them.
  $this
    ->drupalGet('admin/structure/types');
  $this
    ->assertLinkByHref('admin/structure/types/manage/article/fields');
  $this
    ->assertNoLinkByHref('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
    ->assertNoLinkByHref('admin/structure/types/manage/article/fields');
  $this
    ->assertLinkByHref('admin/structure/types/manage/article/display');
}