public function LayoutBuilderAccessTest::testAccessWithoutBundles in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderAccessTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderAccessTest::testAccessWithoutBundles()
Tests Layout Builder access for an entity type that does not have bundles.
@dataProvider providerTestAccessWithoutBundles
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderAccessTest.php, line 167
Class
- LayoutBuilderAccessTest
- Tests access to Layout Builder.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testAccessWithoutBundles(array $permissions, $default_access, $non_editable_access, $editable_access) {
$permissions[] = 'access user profiles';
$user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($user);
$this
->drupalGet('admin/config/people/accounts/display/default/layout');
$this
->assertExpectedAccess($default_access);
$this
->drupalGet($user
->toUrl());
$this
->assertExpectedAccess(TRUE);
$this
->drupalGet($user
->toUrl('edit-form'));
$this
->assertExpectedAccess(TRUE);
$this
->drupalGet('user/' . $user
->id() . '/layout');
$this
->assertExpectedAccess($editable_access);
$non_editable_user = $this
->drupalCreateUser();
$this
->drupalGet($non_editable_user
->toUrl());
$this
->assertExpectedAccess(TRUE);
$this
->drupalGet($non_editable_user
->toUrl('edit-form'));
$this
->assertExpectedAccess(FALSE);
$this
->drupalGet('user/' . $non_editable_user
->id() . '/layout');
$this
->assertExpectedAccess($non_editable_access);
$non_viewable_user = $this
->drupalCreateUser([], 'bad person', FALSE, [
'status' => 0,
]);
$this
->drupalGet($non_viewable_user
->toUrl());
$this
->assertExpectedAccess(FALSE);
$this
->drupalGet($non_viewable_user
->toUrl('edit-form'));
$this
->assertExpectedAccess(FALSE);
$this
->drupalGet('user/' . $non_viewable_user
->id() . '/layout');
$this
->assertExpectedAccess(FALSE);
}