You are here

protected function OpignoStatisticsBrowserTestBase::createGroup in Opigno statistics 3.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/OpignoStatisticsBrowserTestBase.php \Drupal\Tests\opigno_statistics\Functional\OpignoStatisticsBrowserTestBase::createGroup()

Creates a group.

Parameters

array $values: (optional) The values used to create the entity.

Return value

\Drupal\group\Entity\Group The created group entity.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

1 call to OpignoStatisticsBrowserTestBase::createGroup()
OpignoStatisticsTest::testOpignoStatisticsPagesAccess in tests/src/Functional/OpignoStatisticsTest.php
Tests statistics pages access.

File

tests/src/Functional/OpignoStatisticsBrowserTestBase.php, line 92

Class

OpignoStatisticsBrowserTestBase
Provides a base class for Opigno Statistics tests.

Namespace

Drupal\Tests\opigno_statistics\Functional

Code

protected function createGroup(array $values = []) {

  /* @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
  $entity_type_manager = \Drupal::service('entity_type.manager');

  /* @var \Drupal\group\Entity\Group $group */
  $group = $entity_type_manager
    ->getStorage('group')
    ->create($values + [
    'type' => 'learning_path',
    'label' => $this
      ->randomMachineName(),
  ]);
  $group
    ->enforceIsNew();
  $group
    ->save();
  return $group;
}