You are here

public function EntityContext::createMultiple in Lightning Core 8.2

Same name and namespace in other branches
  1. 8.5 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::createMultiple()
  2. 8 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::createMultiple()
  3. 8.3 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::createMultiple()
  4. 8.4 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::createMultiple()

Creates a set of entities from tabular data.

@Given :entity_type entities:

Parameters

string $entity_type: The entity type ID.

\Behat\Gherkin\Node\TableNode $table: The table of entity data.

File

tests/contexts/EntityContext.behat.inc, line 60

Class

EntityContext
Contains miscellaneous step definitions for working with Drupal entities.

Namespace

Acquia\LightningExtension\Context

Code

public function createMultiple($entity_type, TableNode $table) {
  $storage = \Drupal::entityTypeManager()
    ->getStorage($entity_type);
  foreach ($table as $values) {
    $this
      ->save($storage
      ->create($values));
  }
}