protected function MenuAdminPerMenuEntityReferenceTest::setUp in Menu Admin per Menu 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ MenuAdminPerMenuEntityReferenceTest.php, line 73
Class
- MenuAdminPerMenuEntityReferenceTest
- Tests a menu reference field in combination with Menu Admin per Menu.
Namespace
Drupal\Tests\menu_admin_per_menu\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
'display_submitted' => FALSE,
]);
// Create an entity reference field for menus and make it required.
$this
->createEntityReferenceField('node', 'page', 'field_menu', 'Menu', 'menu');
$field_config = FieldConfig::loadByName('node', 'page', 'field_menu');
$field_config
->setRequired(TRUE);
$field_config
->save();
// Add the field to the node form.
$this->container
->get('entity_display.repository')
->getFormDisplay('node', 'page')
->setComponent('field_menu', [
'type' => 'options_select',
])
->save();
$this->adminMenuUser = $this
->createUser([
'access content',
'administer content types',
'edit any page content',
'administer menu',
], 'Admin menu user');
$this->menu1User = $this
->createUser([
'access content',
'administer content types',
'edit any page content',
'administer menu_1 menu items',
], 'Menu 1 user');
$this->menu2User = $this
->createUser([
'access content',
'administer content types',
'edit any page content',
'administer menu_2 menu items',
], 'Menu 2 user');
// Access to menu_3 is added in menu_admin_per_menu_hook_test.
$this->menu3User = $this
->createUser([
'access content',
'administer content types',
'edit any page content',
], 'Menu 3 user');
}