protected function CommerceOrderSyncTest::createEntity in Commerce License 8.2
Creates and saves 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, saved entity.
1 call to CommerceOrderSyncTest::createEntity()
- CommerceOrderSyncTest::setUp in tests/
src/ Kernel/ CommerceOrderSyncTest.php
File
- tests/
src/ Kernel/ CommerceOrderSyncTest.php, line 271
Class
- CommerceOrderSyncTest
- Tests changes to an order are synchronized to the license.
Namespace
Drupal\Tests\commerce_license\KernelCode
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();
$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;
}