You are here

public function FeatureContext::groupCreate in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  2. 8.3 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  3. 8.5 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  4. 8.6 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  5. 8.7 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  6. 8.8 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  7. 10.3.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  8. 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  9. 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::groupCreate()
  10. 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\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 552

Class

FeatureContext
Defines application features from the specific context.

Namespace

Drupal\social\Behat

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;
}