public function OgMenuAccessTest::testDeleteUnsavedAccess in Organic Groups Menu (OG Menu) 8
Tests deletion of unsaved entities.
File
- tests/
src/ Kernel/ OgMenuAccessTest.php, line 236
Class
- OgMenuAccessTest
- Tests access to operations on OG Menu instances.
Namespace
Drupal\Tests\og_menu\KernelCode
public function testDeleteUnsavedAccess() {
// Create an OG Menu but do not save it.
$ogmenu = OgMenu::create([
'label' => $this
->randomString(),
'id' => $this
->randomMachineName(),
]);
// Create an OG Menu Instance but don't save it.
$ogmenu_instance = OgMenuInstance::create([
'id' => $this
->randomMachineName(),
'type' => $ogmenu
->id(),
]);
// Note we are not testing UID 1 which has access to everything, even to
// nonsensical operations such as this.
$user_keys = [
'ogadmin',
'ogmenuadmin',
'groupadmin',
'groupmember',
'authenticated',
];
foreach ($user_keys as $user_key) {
\Drupal::currentUser()
->setAccount($this->users[$user_key]);
foreach ([
'ogmenu',
'ogmenu_instance',
] as $entity_type) {
$message = "User {$user_key} should not be able to delete an unsaved {$entity_type} entity.";
$this
->assertFalse(${$entity_type}
->access('delete'), $message);
}
}
}