NodeAccessMenuLinkTest.php in Zircon Profile 8
File
core/modules/node/src/Tests/NodeAccessMenuLinkTest.php
View source
<?php
namespace Drupal\node\Tests;
use Drupal\user\RoleInterface;
class NodeAccessMenuLinkTest extends NodeTestBase {
public static $modules = array(
'menu_ui',
'block',
);
protected $contentAdminUser;
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('system_menu_block:main');
$this->contentAdminUser = $this
->drupalCreateUser(array(
'access content',
'administer content types',
'administer menu',
));
$this
->config('user.role.' . RoleInterface::ANONYMOUS_ID)
->set('permissions', array())
->save();
}
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
->drupalPostForm('node/add/page', $edit, t('Save'));
$this
->assertLink($menu_link_title);
$this
->drupalLogout();
$this
->drupalGet('');
$this
->assertNoLink($menu_link_title);
$this
->config('user.role.' . RoleInterface::ANONYMOUS_ID)
->set('permissions', array(
'access content',
))
->save();
$this
->drupalGet('');
$this
->assertLink($menu_link_title);
}
}