You are here

public function NodeTypeTest::testNodeTypeFieldUiPermissions in Zircon Profile 8

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

Tests Field UI integration for content types.

File

core/modules/node/src/Tests/NodeTypeTest.php, line 197
Contains \Drupal\node\Tests\NodeTypeTest.

Class

NodeTypeTest
Ensures that node type functions work correctly.

Namespace

Drupal\node\Tests

Code

public function testNodeTypeFieldUiPermissions() {

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

  // Test that the user only sees the actions available to him.
  $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(array(
    'administer content types',
    'administer node display',
  ));
  $this
    ->drupalLogin($admin_user_2);

  // Test that the user only sees the actions available to him.
  $this
    ->drupalGet('admin/structure/types');
  $this
    ->assertNoLinkByHref('admin/structure/types/manage/article/fields');
  $this
    ->assertLinkByHref('admin/structure/types/manage/article/display');
}