Commit 0e454b55 authored by catch's avatar catch

Issue #2502917 by dimaro, rakesh.gectcr, DuaelFr, suhel.rangnekar: Replace...

Issue #2502917 by dimaro, rakesh.gectcr, DuaelFr, suhel.rangnekar: Replace deprecated usage of entity_create used with variable entity types with a direct call to EntityManager::getStorage()->create()
parent ce887237
...@@ -45,7 +45,10 @@ protected function setUp() { ...@@ -45,7 +45,10 @@ protected function setUp() {
parent::setUp(); parent::setUp();
$this->entityTypeId = 'config_test'; $this->entityTypeId = 'config_test';
$this->entityId = 'test_1'; $this->entityId = 'test_1';
entity_create($this->entityTypeId, array('id' => $this->entityId, 'label' => 'Original label'))->save(); $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
->create(array('id' => $this->entityId, 'label' => 'Original label'))
->save();
} }
/** /**
......
...@@ -32,7 +32,10 @@ public function testUUIDConflict() { ...@@ -32,7 +32,10 @@ public function testUUIDConflict() {
$entity_type = 'config_test'; $entity_type = 'config_test';
$id = 'test_1'; $id = 'test_1';
// Load the original configuration entity. // Load the original configuration entity.
entity_create($entity_type, array('id' => $id))->save(); $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => $id))
->save();
$entity = entity_load($entity_type, $id); $entity = entity_load($entity_type, $id);
$original_properties = $entity->toArray(); $original_properties = $entity->toArray();
......
...@@ -234,7 +234,9 @@ protected function createEntity($values, $langcode, $bundle_name = NULL) { ...@@ -234,7 +234,9 @@ protected function createEntity($values, $langcode, $bundle_name = NULL) {
} }
} }
} }
$entity = entity_create($this->entityTypeId, $entity_values); $entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
->create($entity_values);
$entity->save(); $entity->save();
return $entity->id(); return $entity->id();
} }
......
...@@ -292,7 +292,9 @@ function _field_create_entity_from_ids($ids) { ...@@ -292,7 +292,9 @@ function _field_create_entity_from_ids($ids) {
if (isset($ids->bundle) && $bundle_key = $entity_type->getKey('bundle')) { if (isset($ids->bundle) && $bundle_key = $entity_type->getKey('bundle')) {
$id_properties[$bundle_key] = $ids->bundle; $id_properties[$bundle_key] = $ids->bundle;
} }
return entity_create($ids->entity_type, $id_properties); return \Drupal::entityTypeManager()
->getStorage($ids->entity_type)
->create($id_properties);
} }
/** /**
......
...@@ -133,7 +133,9 @@ protected function setUp() { ...@@ -133,7 +133,9 @@ protected function setUp() {
])->save(); ])->save();
} }
for ($i = 0; $i < 10; $i++) { for ($i = 0; $i < 10; $i++) {
$entity = entity_create($this->entityTypeId, array('type' => $bundle)); $entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
->create(array('type' => $bundle));
foreach ($this->fieldStorages as $field_storage) { foreach ($this->fieldStorages as $field_storage) {
$entity->{$field_storage->getName()}->setValue($this->_generateTestFieldValues($field_storage->getCardinality())); $entity->{$field_storage->getName()}->setValue($this->_generateTestFieldValues($field_storage->getCardinality()));
} }
......
...@@ -108,7 +108,9 @@ protected function setUp() { ...@@ -108,7 +108,9 @@ protected function setUp() {
))->save(); ))->save();
// Create the entity to be referenced. // Create the entity to be referenced.
$this->referencedEntity = entity_create($this->entityType, array('name' => $this->randomMachineName())); $this->referencedEntity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => $this->randomMachineName()));
$this->referencedEntity->body = array( $this->referencedEntity->body = array(
'value' => '<p>Hello, world!</p>', 'value' => '<p>Hello, world!</p>',
'format' => 'full_html', 'format' => 'full_html',
...@@ -116,7 +118,9 @@ protected function setUp() { ...@@ -116,7 +118,9 @@ protected function setUp() {
$this->referencedEntity->save(); $this->referencedEntity->save();
// Create another entity to be referenced but do not save it. // Create another entity to be referenced but do not save it.
$this->unsavedReferencedEntity = entity_create($this->entityType, array('name' => $this->randomMachineName())); $this->unsavedReferencedEntity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => $this->randomMachineName()));
$this->unsavedReferencedEntity->body = array( $this->unsavedReferencedEntity->body = array(
'value' => '<p>Hello, unsaved world!</p>', 'value' => '<p>Hello, unsaved world!</p>',
'format' => 'full_html', 'format' => 'full_html',
...@@ -134,7 +138,9 @@ public function testAccess() { ...@@ -134,7 +138,9 @@ public function testAccess() {
$field_name = $this->fieldName; $field_name = $this->fieldName;
$referencing_entity = entity_create($this->entityType, array('name' => $this->randomMachineName())); $referencing_entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => $this->randomMachineName()));
$referencing_entity->save(); $referencing_entity->save();
$referencing_entity->{$field_name}->entity = $this->referencedEntity; $referencing_entity->{$field_name}->entity = $this->referencedEntity;
...@@ -286,7 +292,9 @@ public function testLabelFormatter() { ...@@ -286,7 +292,9 @@ public function testLabelFormatter() {
*/ */
protected function buildRenderArray(array $referenced_entities, $formatter, $formatter_options = array()) { protected function buildRenderArray(array $referenced_entities, $formatter, $formatter_options = array()) {
// Create the entity that will have the entity reference field. // Create the entity that will have the entity reference field.
$referencing_entity = entity_create($this->entityType, array('name' => $this->randomMachineName())); $referencing_entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => $this->randomMachineName()));
$items = $referencing_entity->get($this->fieldName); $items = $referencing_entity->get($this->fieldName);
......
...@@ -32,7 +32,9 @@ function testEntityDisplayBuild() { ...@@ -32,7 +32,9 @@ function testEntityDisplayBuild() {
$this->createFieldWithStorage('_2'); $this->createFieldWithStorage('_2');
$entity_type = 'entity_test'; $entity_type = 'entity_test';
$entity_init = entity_create($entity_type); $entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create();
// Populate values to be displayed. // Populate values to be displayed.
$values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality()); $values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality());
...@@ -186,9 +188,11 @@ function testEntityCache() { ...@@ -186,9 +188,11 @@ function testEntityCache() {
$entity_type = 'entity_test_rev'; $entity_type = 'entity_test_rev';
$this->createFieldWithStorage('_2', $entity_type); $this->createFieldWithStorage('_2', $entity_type);
$entity_init = entity_create($entity_type, array( $entity_init = $this->container->get('entity_type.manager')
'type' => $entity_type, ->getStorage($entity_type)
)); ->create(array(
'type' => $entity_type,
));
// Check that no initial cache entry is present. // Check that no initial cache entry is present.
$cid = "values:$entity_type:" . $entity->id(); $cid = "values:$entity_type:" . $entity->id();
...@@ -293,7 +297,9 @@ function testEntityFormDisplayExtractFormValues() { ...@@ -293,7 +297,9 @@ function testEntityFormDisplayExtractFormValues() {
$this->createFieldWithStorage('_2'); $this->createFieldWithStorage('_2');
$entity_type = 'entity_test'; $entity_type = 'entity_test';
$entity_init = entity_create($entity_type, array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle())); $entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle()));
// Build the form for all fields. // Build the form for all fields.
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->getTargetBundle(), 'default'); $display = entity_get_form_display($entity_type, $this->fieldTestData->field->getTargetBundle(), 'default');
......
...@@ -37,7 +37,9 @@ function testFieldAttachSaveLoad() { ...@@ -37,7 +37,9 @@ function testFieldAttachSaveLoad() {
// TODO : test empty values filtering and "compression" (store consecutive deltas). // TODO : test empty values filtering and "compression" (store consecutive deltas).
// Preparation: create three revisions and store them in $revision array. // Preparation: create three revisions and store them in $revision array.
$values = array(); $values = array();
$entity = entity_create($entity_type); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create();
for ($revision_id = 0; $revision_id < 3; $revision_id++) { for ($revision_id = 0; $revision_id < 3; $revision_id++) {
// Note: we try to insert one extra value. // Note: we try to insert one extra value.
$current_values = $this->_generateTestFieldValues($cardinality + 1); $current_values = $this->_generateTestFieldValues($cardinality + 1);
...@@ -114,7 +116,9 @@ function testFieldAttachLoadMultiple() { ...@@ -114,7 +116,9 @@ function testFieldAttachLoadMultiple() {
// Create one test entity per bundle, with random values. // Create one test entity per bundle, with random values.
foreach ($bundles as $index => $bundle) { foreach ($bundles as $index => $bundle) {
$entities[$index] = entity_create($entity_type, array('id' => $index, 'revision_id' => $index, 'type' => $bundle)); $entities[$index] = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => $index, 'revision_id' => $index, 'type' => $bundle));
$entity = clone($entities[$index]); $entity = clone($entities[$index]);
foreach ($field_names as $field_name) { foreach ($field_names as $field_name) {
if (!$entity->hasField($field_name)) { if (!$entity->hasField($field_name)) {
...@@ -149,7 +153,9 @@ function testFieldAttachSaveEmptyData() { ...@@ -149,7 +153,9 @@ function testFieldAttachSaveEmptyData() {
$entity_type = 'entity_test'; $entity_type = 'entity_test';
$this->createFieldWithStorage('', $entity_type); $this->createFieldWithStorage('', $entity_type);
$entity_init = entity_create($entity_type, array('id' => 1)); $entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => 1));
// Insert: Field is NULL. // Insert: Field is NULL.
$entity = clone $entity_init; $entity = clone $entity_init;
...@@ -200,7 +206,9 @@ function testFieldAttachSaveEmptyDataDefaultValue() { ...@@ -200,7 +206,9 @@ function testFieldAttachSaveEmptyDataDefaultValue() {
$this->fieldTestData->field->save(); $this->fieldTestData->field->save();
// Verify that fields are populated with default values. // Verify that fields are populated with default values.
$entity_init = entity_create($entity_type, array('id' => 1, 'revision_id' => 1)); $entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => 1, 'revision_id' => 1));
$default = field_test_default_value($entity_init, $this->fieldTestData->field); $default = field_test_default_value($entity_init, $this->fieldTestData->field);
$this->assertEqual($entity_init->{$this->fieldTestData->field_name}->getValue(), $default, 'Default field value correctly populated.'); $this->assertEqual($entity_init->{$this->fieldTestData->field_name}->getValue(), $default, 'Default field value correctly populated.');
...@@ -213,7 +221,9 @@ function testFieldAttachSaveEmptyDataDefaultValue() { ...@@ -213,7 +221,9 @@ function testFieldAttachSaveEmptyDataDefaultValue() {
// Verify that prepopulated field values are not overwritten by defaults. // Verify that prepopulated field values are not overwritten by defaults.
$value = array(array('value' => $default[0]['value'] - mt_rand(1, 127))); $value = array(array('value' => $default[0]['value'] - mt_rand(1, 127)));
$entity = entity_create($entity_type, array('type' => $entity_init->bundle(), $this->fieldTestData->field_name => $value)); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('type' => $entity_init->bundle(), $this->fieldTestData->field_name => $value));
$this->assertEqual($entity->{$this->fieldTestData->field_name}->getValue(), $value, 'Prepopulated field value correctly maintained.'); $this->assertEqual($entity->{$this->fieldTestData->field_name}->getValue(), $value, 'Prepopulated field value correctly maintained.');
} }
...@@ -224,7 +234,9 @@ function testFieldAttachDelete() { ...@@ -224,7 +234,9 @@ function testFieldAttachDelete() {
$entity_type = 'entity_test_rev'; $entity_type = 'entity_test_rev';
$this->createFieldWithStorage('', $entity_type); $this->createFieldWithStorage('', $entity_type);
$cardinality = $this->fieldTestData->field_storage->getCardinality(); $cardinality = $this->fieldTestData->field_storage->getCardinality();
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle())); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('type' => $this->fieldTestData->field->getTargetBundle()));
$vids = array(); $vids = array();
// Create revision 0 // Create revision 0
...@@ -292,7 +304,9 @@ function testEntityCreateBundle() { ...@@ -292,7 +304,9 @@ function testEntityCreateBundle() {
FieldConfig::create($this->fieldTestData->field_definition)->save(); FieldConfig::create($this->fieldTestData->field_definition)->save();
// Save an entity with data in the field. // Save an entity with data in the field.
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle())); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('type' => $this->fieldTestData->field->getTargetBundle()));
$values = $this->_generateTestFieldValues($cardinality); $values = $this->_generateTestFieldValues($cardinality);
$entity->{$this->fieldTestData->field_name} = $values; $entity->{$this->fieldTestData->field_name} = $values;
...@@ -336,7 +350,9 @@ function testEntityDeleteBundle() { ...@@ -336,7 +350,9 @@ function testEntityDeleteBundle() {
FieldConfig::create($field)->save(); FieldConfig::create($field)->save();
// Save an entity with data for both fields // Save an entity with data for both fields
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle())); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('type' => $this->fieldTestData->field->getTargetBundle()));
$values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality()); $values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality());
$entity->{$this->fieldTestData->field_name} = $values; $entity->{$this->fieldTestData->field_name} = $values;
$entity->{$field_name} = $this->_generateTestFieldValues(1); $entity->{$field_name} = $this->_generateTestFieldValues(1);
......
...@@ -115,9 +115,9 @@ public function testEntityCountAndHasData() { ...@@ -115,9 +115,9 @@ public function testEntityCountAndHasData() {
$entity_type = 'entity_test_rev'; $entity_type = 'entity_test_rev';
$this->createFieldWithStorage('_2', $entity_type); $this->createFieldWithStorage('_2', $entity_type);
$entity_init = entity_create($entity_type, array( $entity_init = $this->container->get('entity_type.manager')
'type' => $entity_type, ->getStorage($entity_type)
)); ->create(array('type' => $entity_type,));
$cardinality = $this->fieldTestData->field_storage_2->getCardinality(); $cardinality = $this->fieldTestData->field_storage_2->getCardinality();
$this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), FALSE, 'There are no entities with field data.'); $this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), FALSE, 'There are no entities with field data.');
......
...@@ -543,7 +543,9 @@ function testFieldFormAccess() { ...@@ -543,7 +543,9 @@ function testFieldFormAccess() {
// Test that the form structure includes full information for each delta // Test that the form structure includes full information for each delta
// apart from #access. // apart from #access.
$entity = entity_create($entity_type, array('id' => 0, 'revision_id' => 0)); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => 0, 'revision_id' => 0));
$display = entity_get_form_display($entity_type, $entity_type, 'default'); $display = entity_get_form_display($entity_type, $entity_type, 'default');
$form = array(); $form = array();
......
...@@ -76,13 +76,17 @@ function testNestedFieldForm() { ...@@ -76,13 +76,17 @@ function testNestedFieldForm() {
// Create two entities. // Create two entities.
$entity_type = 'entity_test'; $entity_type = 'entity_test';
$entity_1 = entity_create($entity_type, array('id' => 1)); $entity_1 = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => 1));
$entity_1->enforceIsNew(); $entity_1->enforceIsNew();
$entity_1->field_single->value = 0; $entity_1->field_single->value = 0;
$entity_1->field_unlimited->value = 1; $entity_1->field_unlimited->value = 1;
$entity_1->save(); $entity_1->save();
$entity_2 = entity_create($entity_type, array('id' => 2)); $entity_2 = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('id' => 2));
$entity_2->enforceIsNew(); $entity_2->enforceIsNew();
$entity_2->field_single->value = 10; $entity_2->field_single->value = 10;
$entity_2->field_unlimited->value = 11; $entity_2->field_unlimited->value = 11;
......
...@@ -120,7 +120,9 @@ function testTranslatableFieldSaveLoad() { ...@@ -120,7 +120,9 @@ function testTranslatableFieldSaveLoad() {
// Prepare the field translations. // Prepare the field translations.
$entity_type_id = 'entity_test'; $entity_type_id = 'entity_test';
field_test_entity_info_translatable($entity_type_id, TRUE); field_test_entity_info_translatable($entity_type_id, TRUE);
$entity = entity_create($entity_type_id, array('type' => $this->field->getTargetBundle())); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type_id)
->create(array('type' => $this->field->getTargetBundle()));
$field_translations = array(); $field_translations = array();
$available_langcodes = array_keys($this->container->get('language_manager')->getLanguages()); $available_langcodes = array_keys($this->container->get('language_manager')->getLanguages());
$entity->langcode->value = reset($available_langcodes); $entity->langcode->value = reset($available_langcodes);
...@@ -160,7 +162,9 @@ function testTranslatableFieldSaveLoad() { ...@@ -160,7 +162,9 @@ function testTranslatableFieldSaveLoad() {
$translation_langcodes = array_values($translation_langcodes); $translation_langcodes = array_values($translation_langcodes);
$values = array('type' => $field->getTargetBundle(), 'langcode' => $translation_langcodes[0]); $values = array('type' => $field->getTargetBundle(), 'langcode' => $translation_langcodes[0]);
$entity = entity_create($entity_type_id, $values); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type_id)
->create($values);
foreach ($translation_langcodes as $langcode) { foreach ($translation_langcodes as $langcode) {
$values[$this->fieldName][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); $values[$this->fieldName][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality());
$translation = $entity->hasTranslation($langcode) ? $entity->getTranslation($langcode) : $entity->addTranslation($langcode); $translation = $entity->hasTranslation($langcode) ? $entity->getTranslation($langcode) : $entity->addTranslation($langcode);
......
...@@ -96,7 +96,9 @@ function testFieldFormTranslationRevisions() { ...@@ -96,7 +96,9 @@ function testFieldFormTranslationRevisions() {
// Prepare the field translations. // Prepare the field translations.
field_test_entity_info_translatable($this->entityTypeId, TRUE); field_test_entity_info_translatable($this->entityTypeId, TRUE);
$entity = entity_create($this->entityTypeId); $entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
->create();
$available_langcodes = array_flip(array_keys($this->container->get('language_manager')->getLanguages())); $available_langcodes = array_flip(array_keys($this->container->get('language_manager')->getLanguages()));
$field_name = $this->fieldStorage->getName(); $field_name = $this->fieldStorage->getName();
......
...@@ -70,11 +70,15 @@ protected function setUp() { ...@@ -70,11 +70,15 @@ protected function setUp() {
))->save(); ))->save();
// Create the entity to be referenced. // Create the entity to be referenced.
$this->targetEntity = entity_create($this->entityType, array('name' => $this->randomMachineName())); $this->targetEntity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => $this->randomMachineName()));
$this->targetEntity->save(); $this->targetEntity->save();
// Create the entity that will have the entity reference field. // Create the entity that will have the entity reference field.
$this->entity = entity_create($this->entityType, array('name' => $this->randomMachineName())); $this->entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => $this->randomMachineName()));
$this->entity->save(); $this->entity->save();
$this->entity->{$this->fieldName}->entity = $this->targetEntity; $this->entity->{$this->fieldName}->entity = $this->targetEntity;
$this->uri = $this->getAbsoluteUri($this->entity); $this->uri = $this->getAbsoluteUri($this->entity);
......
...@@ -54,7 +54,9 @@ protected function setUp() { ...@@ -54,7 +54,9 @@ protected function setUp() {
// request. // request.
$serializer = $this->container->get('serializer'); $serializer = $this->container->get('serializer');
$entity_values = $this->entityValues($this->testEntityType); $entity_values = $this->entityValues($this->testEntityType);
$entity = entity_create($this->testEntityType, $entity_values); $entity = $this->container->get('entity_type.manager')
->getStorage($this->testEntityType)
->create($entity_values);
$this->serialized = $serializer->serialize($entity, $this->defaultFormat); $this->serialized = $serializer->serialize($entity, $this->defaultFormat);
} }
......
...@@ -183,7 +183,9 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { ...@@ -183,7 +183,9 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) {
* The new entity object. * The new entity object.
*/ */
protected function entityCreate($entity_type) { protected function entityCreate($entity_type) {
return entity_create($entity_type, $this->entityValues($entity_type)); return $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create($this->entityValues($entity_type));
} }
/** /**
......
...@@ -50,7 +50,9 @@ public function testPatchUpdate() { ...@@ -50,7 +50,9 @@ public function testPatchUpdate() {
'value' => $this->randomString(), 'value' => $this->randomString(),
'format' => 'plain_text', 'format' => 'plain_text',
)); ));
$patch_entity = entity_create($entity_type, $patch_values); $patch_entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create($patch_values);
// We don't want to overwrite the UUID. // We don't want to overwrite the UUID.
$patch_entity->set('uuid', NULL); $patch_entity->set('uuid', NULL);
$serialized = $serializer->serialize($patch_entity, $this->defaultFormat, $context); $serialized = $serializer->serialize($patch_entity, $this->defaultFormat, $context);
......
...@@ -52,11 +52,17 @@ public function testCRUD() { ...@@ -52,11 +52,17 @@ public function testCRUD() {
*/ */
protected function assertCRUD($entity_type, UserInterface $user1) { protected function assertCRUD($entity_type, UserInterface $user1) {
// Create some test entities. // Create some test entities.
$entity = entity_create($entity_type, array('name' => 'test', 'user_id' => $user1->id())); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('name' => 'test', 'user_id' => $user1->id()));
$entity->save(); $entity->save();
$entity = entity_create($entity_type, array('name' => 'test2', 'user_id' => $user1->id())); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('name' => 'test2', 'user_id' => $user1->id()));
$entity->save(); $entity->save();
$entity = entity_create($entity_type, array('name' => 'test', 'user_id' => NULL)); $entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create(array('name' => 'test', 'user_id' => NULL));
$entity->save(); $entity->save();
$entities = array_values(entity_load_multiple_by_properties($entity_type, array('name' => 'test'))); $entities = array_values(entity_load_multiple_by_properties($entity_type, array('name' => 'test')));
......
...@@ -50,15 +50,21 @@ protected function setUp() { ...@@ -50,15 +50,21 @@ protected function setUp() {
*/ */
function testEntityReferenceAutocompletion() { function testEntityReferenceAutocompletion() {
// Add an entity with a slash in its name. // Add an entity with a slash in its name.
$entity_1 = entity_create($this->entityType, array('name' => '10/16/2011')); $entity_1 = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => '10/16/2011'));
$entity_1->save(); $entity_1->save();
// Add another entity that differs after the slash character. // Add another entity that differs after the slash character.
$entity_2 = entity_create($this->entityType, array('name' => '10/17/2011')); $entity_2 = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
->create(array('name' => '10/17/2011'));
$entity_2->save(); $entity_2->save();