protected function CartOrderPlacedTest::createEntity in Commerce Core 8.2
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.
1 call to CartOrderPlacedTest::createEntity()
- CartOrderPlacedTest::setUp in modules/cart/ tests/ src/ Kernel/ CartOrderPlacedTest.php 
File
- modules/cart/ tests/ src/ Kernel/ CartOrderPlacedTest.php, line 89 
Class
- CartOrderPlacedTest
- Tests the unsetting of the cart flag when order is placed.
Namespace
Drupal\Tests\commerce_cart\KernelCode
protected function createEntity($entity_type, array $values) {
  /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage($entity_type);
  $entity = $storage
    ->create($values);
  $status = $entity
    ->save();
  $this
    ->assertEquals(SAVED_NEW, $status, new FormattableMarkup('Created %label entity %type.', [
    '%label' => $entity
      ->getEntityType()
      ->getLabel(),
    '%type' => $entity
      ->id(),
  ]));
  // The newly saved entity isn't identical to a loaded one, and would fail
  // comparisons.
  $entity = $storage
    ->load($entity
    ->id());
  return $entity;
}