You are here

public function UserPermissionsTest::testAccessContentPermission in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Functional/UserPermissionsTest.php \Drupal\Tests\user\Functional\UserPermissionsTest::testAccessContentPermission()
  2. 10 core/modules/user/tests/src/Functional/UserPermissionsTest.php \Drupal\Tests\user\Functional\UserPermissionsTest::testAccessContentPermission()

Verify 'access content' is listed in the correct location.

File

core/modules/user/tests/src/Functional/UserPermissionsTest.php, line 182

Class

UserPermissionsTest
Verify that role permissions can be added and removed via the permissions page.

Namespace

Drupal\Tests\user\Functional

Code

public function testAccessContentPermission() {
  $this
    ->drupalLogin($this->adminUser);

  // When Node is not installed the 'access content' permission is listed next
  // to 'access site reports'.
  $this
    ->drupalGet('admin/people/permissions');
  $next_row = $this
    ->xpath('//tr[@data-drupal-selector=\'edit-permissions-access-content\']/following-sibling::tr[1]');
  $this
    ->assertEqual('edit-permissions-access-site-reports', $next_row[0]
    ->getAttribute('data-drupal-selector'));

  // When Node is installed the 'access content' permission is listed next to
  // to 'view own unpublished content'.
  \Drupal::service('module_installer')
    ->install([
    'node',
  ]);
  $this
    ->drupalGet('admin/people/permissions');
  $next_row = $this
    ->xpath('//tr[@data-drupal-selector=\'edit-permissions-access-content\']/following-sibling::tr[1]');
  $this
    ->assertEqual('edit-permissions-view-own-unpublished-content', $next_row[0]
    ->getAttribute('data-drupal-selector'));
}