You are here

public function FeatureContext::groupCreate in Open Social 8

Same name and namespace in other branches
  1. 8.2 tests/behat/features/bootstrap/FeatureContext.php \FeatureContext::groupCreate()

Create a group.

Return value

object The created group.

1 call to FeatureContext::groupCreate()
FeatureContext::createGroups in tests/behat/features/bootstrap/FeatureContext.php
Creates group of a given type provided in the form: | title | description | author | type | language | My title | My description | username | open_group | en | ... | ... | ... | ... | ...

File

tests/behat/features/bootstrap/FeatureContext.php, line 497

Class

FeatureContext
Defines application features from the specific context.

Code

public function groupCreate($group) {
  $account = user_load_by_name($group->author);
  if ($account
    ->id() !== 0) {
    $account_uid = $account
      ->id();
  }
  else {
    throw new \Exception(sprintf("User with username '%s' does not exist.", $username));
  }

  // Let's create some groups.
  $group_object = Group::create([
    'langcode' => $group->language,
    'uid' => $account_uid,
    'type' => $group->type,
    'label' => $group->title,
    'field_group_description' => $group->description,
  ]);
  $group_object
    ->save();
  return $group_object;
}