You are here

protected function GetBundleByBundleTest::setUp in Organic groups 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Entity/GetBundleByBundleTest.php, line 65

Class

GetBundleByBundleTest
Tests retrieving group content bundles by group bundles and vice versa.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installConfig([
    'og',
  ]);
  $this
    ->installEntitySchema('block_content');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('og_membership');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('system', 'sequences');
  $this->groupTypeManager = $this->container
    ->get('og.group_type_manager');
  $this->cache = $this->container
    ->get('cache.data');

  // Create four groups of two different entity types.
  for ($i = 0; $i < 2; $i++) {
    $bundle = "group_{$i}";
    NodeType::create([
      'name' => $this
        ->randomString(),
      'type' => $bundle,
    ])
      ->save();
    Og::groupTypeManager()
      ->addGroup('node', $bundle);
    BlockContentType::create([
      'id' => $bundle,
    ])
      ->save();
    Og::groupTypeManager()
      ->addGroup('block_content', $bundle);
  }
}