You are here

protected function SelectionHandlerTest::createGroups in Organic groups 8

Creating groups for a given user.

Parameters

int $amount: The number of groups to create.

\Drupal\user\Entity\User $user: The user object which owns the groups.

Return value

ContentEntityBase[] An array of group entities.

1 call to SelectionHandlerTest::createGroups()
SelectionHandlerTest::testSelectionHandlerResults in tests/src/Kernel/Entity/SelectionHandlerTest.php
Testing OG selection handler results.

File

tests/src/Kernel/Entity/SelectionHandlerTest.php, line 196

Class

SelectionHandlerTest
Tests entity reference selection plugins.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

protected function createGroups($amount, User $user) {
  $groups = [];
  for ($i = 0; $i <= $amount; $i++) {
    $group = Node::create([
      'title' => $this
        ->randomString(),
      'uid' => $user
        ->id(),
      'type' => $this->groupBundle,
    ]);
    $group
      ->save();
    $groups[] = $group
      ->id();
  }
  return $groups;
}