protected function CommerceBrowserTestTrait::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.
109 calls to CommerceBrowserTestTrait::createEntity()
- AddressBookTest::testCreateAccess in modules/
order/ tests/ src/ FunctionalJavascript/ AddressBookTest.php - Tests the add form access checking.
- AddressBookTest::testDefaultOverview in modules/
order/ tests/ src/ FunctionalJavascript/ AddressBookTest.php - Tests the address book overview page with the default profile type.
- AddressBookTest::testExtendedOverview in modules/
order/ tests/ src/ FunctionalJavascript/ AddressBookTest.php - Tests the address book overview page with several profile types.
- AddressBookTest::testFallback in modules/
order/ tests/ src/ FunctionalJavascript/ AddressBookTest.php - Tests the fallback to the default profile UI.
- AddressBookTest::testOverviewAccess in modules/
order/ tests/ src/ FunctionalJavascript/ AddressBookTest.php - Tests the overview access checking.
File
- tests/
src/ Traits/ CommerceBrowserTestTrait.php, line 25
Class
- CommerceBrowserTestTrait
- Provides a trait for Commerce functional tests.
Namespace
Drupal\Tests\commerce\TraitsCode
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;
}