You are here

protected function TrainingContentTrait::createGroup in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x tests/src/Functional/TrainingContentTrait.php \Drupal\Tests\opigno_learning_path\Functional\TrainingContentTrait::createGroup()

Creates a Training.

Parameters

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

Return value

\Drupal\group\Entity\Group The created group entity of type learning_path.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

7 calls to TrainingContentTrait::createGroup()
OpignoLinkConditionTest::testLinkCondition in tests/src/Functional/OpignoLinkConditionTest.php
Test.
OpignoModuleScoreTest::testModuleScoreDisplay in tests/src/Functional/OpignoModuleScoreTest.php
Test Opigno Module score on different pages (achievements, statistics etc).
TrainingAccessTest::testTrainingStart in tests/src/Functional/TrainingAccessTest.php
Tests which users can subscribe and start a training.
TrainingAccessTest::testTrainingVisibility in tests/src/Functional/TrainingAccessTest.php
Tests training visibility for users.
TrainingCompleteTest::testTrainingComplete in tests/src/Functional/TrainingCompleteTest.php
Tests training visibility for users.

... See full list

File

tests/src/Functional/TrainingContentTrait.php, line 30

Class

TrainingContentTrait
Trait TrainingContentTrait.

Namespace

Drupal\Tests\opigno_learning_path\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;
}