MenuAdminPerMenuPermissionsTest.php in Menu Admin per Menu 8
File
tests/src/Kernel/MenuAdminPerMenuPermissionsTest.php
View source
<?php
namespace Drupal\Tests\menu_admin_per_menu\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\menu_admin_per_menu\MenuAdminPerMenuPermissions;
class MenuAdminPerMenuPermissionsTest extends KernelTestBase {
protected static $modules = [
'menu_admin_per_menu',
'menu_ui',
'system',
];
protected $menuAdminPerMenuPermissions;
protected $menuStorage;
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('menu');
$this
->installConfig('system');
$this->menuAdminPerMenuPermissions = new MenuAdminPerMenuPermissions();
$this->menuStorage = $this->container
->get('entity_type.manager')
->getStorage('menu');
}
public function testPermissions() {
$this
->assertEquals([
'administer admin menu items',
'administer footer menu items',
'administer main menu items',
'administer tools menu items',
'administer account menu items',
], array_keys($this->menuAdminPerMenuPermissions
->permissions()));
$menu = $this->menuStorage
->create([
'id' => 'my_custom_menu',
'label' => 'My custom menu',
]);
$menu
->save();
$this
->assertEquals([
'administer admin menu items',
'administer footer menu items',
'administer main menu items',
'administer my_custom_menu menu items',
'administer tools menu items',
'administer account menu items',
], array_keys($this->menuAdminPerMenuPermissions
->permissions()));
$this->menuStorage
->delete([
$menu,
]);
$this
->assertEquals([
'administer admin menu items',
'administer footer menu items',
'administer main menu items',
'administer tools menu items',
'administer account menu items',
], array_keys($this->menuAdminPerMenuPermissions
->permissions()));
}
}