You are here

private function CommerceMigrateBaseTestCase::getEntityWrapper in Commerce Migrate 7

Load entity by property.

Parameters

string $entity_type: Entity type.

string $property: Property in entity schema.

string $value: Expected value of a property.

Return value

\EntityDrupalWrapper|\EntityMetadataWrapper Entity wrapper.

Throws

\Exception

2 calls to CommerceMigrateBaseTestCase::getEntityWrapper()
CommerceMigrateBaseTestCase::getOrder in tests/commerce_migrate_base.test
Load an order by number.
CommerceMigrateBaseTestCase::getProduct in tests/commerce_migrate_base.test
Load product by SKU.

File

tests/commerce_migrate_base.test, line 261
Base facade for "Commerce Migrate" tests.

Class

CommerceMigrateBaseTestCase
Class CommerceMigrateBaseTestCase.

Code

private function getEntityWrapper($entity_type, $property, $value) {
  $entity = entity_load($entity_type, FALSE, array(
    $property => $value,
  ));
  if (empty($entity)) {
    throw new \Exception(format_string('Entity of "@entity_type" cannot be loaded using "@property" property with "@value" value.', array(
      '@entity_type' => $entity_type,
      '@property' => $property,
      '@value' => $value,
    )));
  }
  return entity_metadata_wrapper($entity_type, reset($entity));
}