You are here

protected function TrainingContentTrait::createOpignoModule 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::createOpignoModule()

Create module with activities.

Parameters

array $values: Module values.

Return value

\Drupal\opigno_module\Entity\OpignoModule The Opigno module with activities.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

5 calls to TrainingContentTrait::createOpignoModule()
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).
TrainingCompleteTest::testTrainingComplete in tests/src/Functional/TrainingCompleteTest.php
Tests training visibility for users.
TrainingEditInterfaceAccessTest::testAccessEditPageTraining in tests/src/Functional/TrainingEditInterfaceAccessTest.php
Tests which users can subscribe and start a training.
TrainingEditInterfaceTest::testTrainingInterfaceAccess in tests/src/FunctionalJavascript/TrainingEditInterfaceTest.php
Tests Training Interface Access.

File

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

Class

TrainingContentTrait
Trait TrainingContentTrait.

Namespace

Drupal\Tests\opigno_learning_path\Functional

Code

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

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

  // Create module.

  /* @var \Drupal\opigno_module\Entity\OpignoModule $module */
  $module = $entity_type_manager
    ->getStorage('opigno_module')
    ->create($values + [
    'name' => $this
      ->randomMachineName(),
  ]);
  $module
    ->save();
  $activities = $this
    ->createActivities([
    'type' => 'opigno_long_answer',
  ], 1);

  // Add activities to a modules.
  $opigno_module_controller = \Drupal::service('opigno_module.opigno_module');
  $opigno_module_controller
    ->activitiesToModule($activities, $module);
  return $module;
}