You are here

protected function OrderReportGenerateFormTest::createEntity in Commerce Reporting 8

Creates a new entity.

Parameters

string $entity_type: The entity type to be created.

array $values: An array of settings. Example: 'id' => 'foo'.

Return value

\Drupal\Core\Entity\EntityInterface A new entity.

Overrides CommerceBrowserTestTrait::createEntity

1 call to OrderReportGenerateFormTest::createEntity()
OrderReportGenerateFormTest::setUp in tests/src/Functional/OrderReportGenerateFormTest.php

File

tests/src/Functional/OrderReportGenerateFormTest.php, line 192

Class

OrderReportGenerateFormTest
Tests the OrderReportGenerateForm.

Namespace

Drupal\Tests\commerce_reports\Functional

Code

protected function createEntity($entity_type, array $values) {

  /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
  $storage = \Drupal::service('entity_type.manager')
    ->getStorage($entity_type);
  $entity = $storage
    ->create($values);
  $status = $entity
    ->save();

  // The newly saved entity isn't identical to a loaded one, and would fail
  // comparisons.
  $entity = $storage
    ->load($entity
    ->id());
  return $entity;
}