3 namespace Drupal\Tests\node\Functional;
5 use Drupal\user\RoleInterface;
8 * Tests the interaction of the node access system with menu links.
12 class NodeAccessMenuLinkTest extends NodeTestBase {
19 public static $modules = ['menu_ui', 'block'];
22 * A user with permission to manage menu links and create nodes.
24 * @var \Drupal\user\UserInterface
26 protected $contentAdminUser;
28 protected function setUp() {
31 $this->drupalPlaceBlock('system_menu_block:main');
33 $this->contentAdminUser = $this->drupalCreateUser([
35 'administer content types',
39 $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', [])->save();
43 * SA-CORE-2015-003: Tests menu links to nodes when node access is restricted.
45 public function testNodeAccessMenuLink() {
47 $menu_link_title = $this->randomString();
49 $this->drupalLogin($this->contentAdminUser);
51 'title[0][value]' => $this->randomString(),
52 'body[0][value]' => $this->randomString(),
54 'menu[title]' => $menu_link_title,
56 $this->drupalPostForm('node/add/page', $edit, t('Save'));
57 $this->assertLink($menu_link_title);
59 // Ensure anonymous users without "access content" permission do not see
61 $this->drupalLogout();
63 $this->assertNoLink($menu_link_title);
65 // Ensure anonymous users with "access content" permission see this menu
67 $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', ['access content'])->save();
69 $this->assertLink($menu_link_title);