Same filename and directory in other branches
- 8.9.x core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php
- 9 core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php
Namespace
Drupal\Tests\node\Functional
File
core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\node\Functional;
use Drupal\user\RoleInterface;
class NodeAccessMenuLinkTest extends NodeTestBase {
protected static $modules = [
'menu_ui',
'block',
];
protected $defaultTheme = 'stark';
protected $contentAdminUser;
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('system_menu_block:main');
$this->contentAdminUser = $this
->drupalCreateUser([
'access content',
'administer content types',
'bypass node access',
'administer menu',
]);
$this
->config('user.role.' . RoleInterface::ANONYMOUS_ID)
->set('permissions', [])
->save();
}
public function testNodeAccessMenuLink() {
$menu_link_title = $this
->randomString();
$this
->drupalLogin($this->contentAdminUser);
$edit = [
'title[0][value]' => $this
->randomString(),
'body[0][value]' => $this
->randomString(),
'menu[enabled]' => 1,
'menu[title]' => $menu_link_title,
];
$this
->drupalGet('node/add/page');
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->linkExists($menu_link_title);
$this
->drupalLogout();
$this
->drupalGet('');
$this
->assertSession()
->linkNotExists($menu_link_title);
$this
->config('user.role.' . RoleInterface::ANONYMOUS_ID)
->set('permissions', [
'access content',
])
->save();
$this
->drupalGet('');
$this
->assertSession()
->linkExists($menu_link_title);
}
}
Classes