protected function GroupTypeConditionTest::setUp in Organic groups 8
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ GroupTypeConditionTest.php, line 55
Class
- GroupTypeConditionTest
- Tests the GroupType condition plugin.
Namespace
Drupal\Tests\og\KernelCode
protected function setUp() : void {
parent::setUp();
$this->conditionManager = $this->container
->get('plugin.manager.condition');
$this->groupTypeManager = $this->container
->get('og.group_type_manager');
// Add membership and config schema.
$this
->installConfig([
'og',
]);
$this
->installEntitySchema('entity_test');
$this
->installEntitySchema('node');
$this
->installEntitySchema('user');
$this
->installSchema('system', [
'sequences',
]);
// Create three test groups of different types.
for ($i = 0; $i < 2; $i++) {
$bundle = "node{$i}";
NodeType::create([
'name' => $this
->randomString(),
'type' => $bundle,
])
->save();
$this->groupTypeManager
->addGroup('node', $bundle);
$group = Node::create([
'title' => $this
->randomString(),
'type' => $bundle,
]);
$group
->save();
$this->groups[$bundle] = $group;
}
// The Entity Test entity doesn't have 'real' bundles, so we don't need to
// create one, we can just add the group to the fake bundle.
$bundle = 'entity_test';
$this->groupTypeManager
->addGroup('entity_test', $bundle);
$group = EntityTest::create([
'type' => $bundle,
'name' => $this
->randomString(),
]);
$group
->save();
$this->groups[$bundle] = $group;
}