GroupBehaviorInvocationTest.php in Rabbit Hole 2.x
File
modules/rh_group/tests/src/Functional/GroupBehaviorInvocationTest.php
View source
<?php
namespace Drupal\Tests\rh_group\Functional;
use Drupal\Tests\rabbit_hole\Functional\RabbitHoleBehaviorInvocationTestBase;
class GroupBehaviorInvocationTest extends RabbitHoleBehaviorInvocationTestBase {
protected $entityType = 'group';
public static $modules = [
'rh_group',
'group',
];
protected $groupType;
protected function createEntityBundle($action = NULL) {
$storage = \Drupal::entityTypeManager()
->getStorage('group_type');
$group_type = $storage
->create([
'id' => mb_strtolower($this
->randomMachineName()),
'label' => $this
->randomString(),
]);
$storage
->save($group_type);
$this->groupType = $group_type;
if (isset($action)) {
$this->behaviorSettingsManager
->saveBehaviorSettings([
'action' => $action,
'allow_override' => TRUE,
], 'group_type', $this->groupType
->id());
}
return $this->groupType
->id();
}
protected function createEntity($action = NULL) {
$values = [];
if (isset($action)) {
$values['rh_action'] = $action;
}
$storage = \Drupal::entityTypeManager()
->getStorage('group');
$group = $storage
->create($values + [
'type' => $this->groupType
->id(),
'label' => $this
->randomString(),
]);
$group
->enforceIsNew();
$storage
->save($group);
return $group;
}
protected function getViewPermissions() {
return [
'bypass group access',
];
}
}