Commit 899cb523 authored by catch's avatar catch

Issue #2723591 by marvin_B8: Remove entity_load* usage for entity_test, entity_test* entity types

parent 9aa63fd1
......@@ -112,7 +112,9 @@ public function testCacheTags() {
// Load commented entity so comment_count gets computed.
// @todo Remove the $reset = TRUE parameter after
// https://www.drupal.org/node/597236 lands. It's a temporary work-around.
$commented_entity = entity_load('entity_test', $commented_entity->id(), TRUE);
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
$storage->resetCache([$commented_entity->id()]);
$commented_entity = $storage->load($commented_entity->id());
// Verify cache tags on the rendered entity when it has comments.
$build = \Drupal::entityManager()
......
......@@ -43,7 +43,9 @@ public function testCommentItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id, TRUE);
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
$storage->resetCache([$id]);
$entity = $storage->load($id);
$this->assertTrue($entity->comment instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->comment[0] instanceof CommentItemInterface, 'Field item implements interface.');
......
......@@ -7,6 +7,7 @@
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Datetime\Entity\DateFormat;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\Node;
......@@ -197,7 +198,7 @@ function testDateField() {
// interval will use this, force the test date to use UTC and not the local
// or user timezome.
$timestamp = REQUEST_TIME - 87654321;
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$field_name = $this->fieldStorage->getName();
$date = DrupalDateTime::createFromTimestamp($timestamp, 'UTC');
$entity->{$field_name}->value = $date->format($date_format);
......@@ -224,7 +225,7 @@ function testDateField() {
// interval will use this, force the test date to use UTC and not the local
// or user timezome.
$timestamp = REQUEST_TIME + 87654321;
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$field_name = $this->fieldStorage->getName();
$date = DrupalDateTime::createFromTimestamp($timestamp, 'UTC');
$entity->{$field_name}->value = $date->format($date_format);
......@@ -337,7 +338,7 @@ function testDatetimeField() {
// interval will use this, force the test date to use UTC and not the local
// or user timezome.
$timestamp = REQUEST_TIME - 87654321;
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$field_name = $this->fieldStorage->getName();
$date = DrupalDateTime::createFromTimestamp($timestamp, 'UTC');
$entity->{$field_name}->value = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
......@@ -364,7 +365,7 @@ function testDatetimeField() {
// interval will use this, force the test date to use UTC and not the local
// or user timezome.
$timestamp = REQUEST_TIME + 87654321;
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$field_name = $this->fieldStorage->getName();
$date = DrupalDateTime::createFromTimestamp($timestamp, 'UTC');
$entity->{$field_name}->value = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
......@@ -859,7 +860,7 @@ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
if ($reset) {
\Drupal::entityManager()->getStorage('entity_test')->resetCache(array($id));
}
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode);
$build = $display->build($entity);
$output = \Drupal::service('renderer')->renderRoot($build);
......
......@@ -57,7 +57,7 @@ public function testDateTimeItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_datetime instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_datetime[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_datetime->value, $value);
......@@ -70,7 +70,7 @@ public function testDateTimeItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_datetime->value, $new_value);
// Test the generateSampleValue() method.
......@@ -90,7 +90,7 @@ public function testSetValue() {
$entity->save();
// Load the entity and ensure the field was saved correctly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_datetime[0]->value, $value, 'DateTimeItem::setValue() works with string value.');
// Test DateTimeItem::setValue() using property array.
......@@ -100,7 +100,7 @@ public function testSetValue() {
$entity->save();
// Load the entity and ensure the field was saved correctly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_datetime[0]->value, $value, 'DateTimeItem::setValue() works with array value.');
}
......@@ -116,7 +116,7 @@ public function testSetValueProperty() {
$entity->save();
// Load the entity and ensure the field was saved correctly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_datetime[0]->value, $value, '"Value" property can be set directly.');
}
......
......@@ -121,7 +121,9 @@ protected function setUp() {
* Returns the selected in-place editor.
*/
protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
$entity = entity_load('entity_test', $entity_id, TRUE);
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
$storage->resetCache([$entity_id]);
$entity = $storage->load($entity_id);
$items = $entity->get($field_name);
$options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name);
return $this->editorSelector->getEditor($options['type'], $items);
......@@ -172,7 +174,7 @@ public function testMetadata() {
$entity->{$this->fieldName}->value = 'Test';
$entity->{$this->fieldName}->format = 'full_html';
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
// Verify metadata.
$items = $entity->get($this->fieldName);
......@@ -209,7 +211,7 @@ public function testGetUntransformedTextCommand() {
$entity->{$this->fieldName}->value = 'Test';
$entity->{$this->fieldName}->format = 'full_html';
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
// Verify AJAX response.
$controller = new EditorController();
......
......@@ -3,6 +3,7 @@
namespace Drupal\field\Tests\Boolean;
use Drupal\Component\Utility\Unicode;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
......@@ -106,7 +107,7 @@ function testBooleanField() {
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
// Verify that boolean value is displayed.
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
......
......@@ -3,6 +3,7 @@
namespace Drupal\field\Tests\Email;
use Drupal\Component\Utility\Unicode;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
......@@ -96,7 +97,7 @@ function testEmailField() {
$this->assertRaw($value);
// Verify that a mailto link is displayed.
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
......
......@@ -73,7 +73,7 @@ public function testImportDeleteUninstall() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_tel->value, $value);
$this->assertEqual($entity->field_tel[0]->value, $value);
......
......@@ -6,6 +6,7 @@
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Form\FormState;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\entity_test\Entity\EntityTestBaseFieldDisplay;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
......@@ -130,7 +131,7 @@ function testFieldFormSingle() {
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was saved');
// Display edit form.
......@@ -146,7 +147,7 @@ function testFieldFormSingle() {
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated');
$this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated');
// Empty the field.
......@@ -157,7 +158,7 @@ function testFieldFormSingle() {
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
$this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated');
$this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->{$field_name}->isEmpty(), 'Field was emptied');
}
......@@ -189,7 +190,7 @@ function testFieldFormDefaultValue() {
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created.');
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->{$field_name}->isEmpty(), 'Field is now empty.');
}
......@@ -218,7 +219,7 @@ function testFieldFormSingleRequired() {
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was saved');
// Edit with missing required value.
......@@ -299,7 +300,7 @@ function testFieldFormUnlimited() {
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
ksort($field_values);
$field_values = array_values($field_values);
$this->assertIdentical($entity->{$field_name}->getValue(), $field_values, 'Field values were saved in the correct order');
......@@ -474,7 +475,7 @@ function testFieldFormMultipleWidget() {
$id = $match[1];
// Check that the values were saved.
$entity_init = entity_load('entity_test', $id);
$entity_init = EntityTest::load($id);
$this->assertFieldValues($entity_init, $field_name, array(1, 2, 3));
// Display the form, check that the values are correctly filled in.
......
......@@ -3,6 +3,7 @@
namespace Drupal\field\Tests\String;
use Drupal\Component\Utility\Unicode;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
......@@ -91,7 +92,7 @@ function _testTextfieldWidgets($field_type, $widget_type) {
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
// Display the entity.
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
......
......@@ -55,7 +55,7 @@ public function testBooleanItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_boolean instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_boolean[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_boolean->value, $value);
......@@ -68,7 +68,7 @@ public function testBooleanItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_boolean->value, $new_value);
// Test sample item generation.
......
......@@ -52,7 +52,7 @@ public function testEmailItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_email instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_email[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_email->value, $value);
......@@ -65,7 +65,7 @@ public function testEmailItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_email->value, $new_value);
// Test sample item generation.
......
......@@ -116,7 +116,7 @@ public function testContentEntityReferenceItem() {
$entity->name->value = $this->randomMachineName();
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->field_test_taxonomy_term instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test_taxonomy_term[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_test_taxonomy_term->target_id, $tid);
......@@ -212,7 +212,7 @@ public function testConfigEntityReferenceItem() {
$entity->name->value = $this->randomMachineName();
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->field_test_taxonomy_vocabulary instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test_taxonomy_vocabulary[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_test_taxonomy_vocabulary->target_id, $referenced_entity_id);
......
......@@ -70,7 +70,7 @@ public function testImportDeleteUninstall() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_test->value, $value);
$this->assertEqual($entity->field_test[0]->value, $value);
$this->assertEqual($entity->field_int->value, '99');
......@@ -134,7 +134,7 @@ public function testImportAlreadyDeletedUninstall() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_test->value, $value);
}
......
......@@ -61,7 +61,7 @@ public function testNumberItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_integer instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_integer[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_integer->value, $integer);
......@@ -88,7 +88,7 @@ public function testNumberItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_integer->value, $new_integer);
$this->assertEqual($entity->field_float->value, $new_float);
$this->assertEqual($entity->field_decimal->value, $new_decimal);
......
......@@ -60,7 +60,7 @@ public function testShapeItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->{$this->fieldName}->shape, $shape);
......@@ -78,7 +78,7 @@ public function testShapeItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$this->fieldName}->shape, $new_shape);
$this->assertEqual($entity->{$this->fieldName}->color, $new_color);
}
......
......@@ -59,7 +59,7 @@ public function testTestItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->{$this->fieldName}->value, $value);
......@@ -72,7 +72,7 @@ public function testTestItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$this->fieldName}->value, $new_value);
// Test the schema for this field type.
......
......@@ -83,7 +83,7 @@ public function testFileItem() {
$entity->name->value = $this->randomMachineName();
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->file_test instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->file_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->file_test->target_id, $this->file->id());
......
......@@ -74,7 +74,7 @@ public function testImageItem() {
$entity->name->value = $this->randomMachineName();
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->image_test instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->image_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->image_test->target_id, $this->image->id());
......
......@@ -624,7 +624,7 @@ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
if ($reset) {
$this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
}
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), $view_mode);
$content = $display->build($entity);
$output = \Drupal::service('renderer')->renderRoot($content);
......
......@@ -83,7 +83,7 @@ public function testLinkItem() {
// Verify that the field value is changed.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_test instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_test->uri, $parsed_url['path']);
......@@ -98,7 +98,7 @@ public function testLinkItem() {
$entity->name->value = $this->randomMachineName();
$entity->save();
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_test->uri, $parsed_url['path']);
$this->assertEqual($entity->field_test->options['attributes']['class'], $class);
$this->assertEqual($entity->field_test->options['query'], $parsed_url['query']);
......@@ -118,7 +118,7 @@ public function testLinkItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_test->uri, $new_url);
$this->assertEqual($entity->field_test->title, $new_title);
$this->assertEqual($entity->field_test->options['attributes']['class'], $new_class);
......
......@@ -37,7 +37,9 @@ protected function setUp() {
* Returns the in-place editor that Quick Edit selects.
*/
protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
$entity = entity_load('entity_test', $entity_id, TRUE);
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
$storage->resetCache([$entity_id]);
$entity = $storage->load($entity_id);
$items = $entity->get($field_name);
$options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name);
return $this->editorSelector->getEditor($options['type'], $items);
......
......@@ -93,7 +93,7 @@ public function testSimpleEntityType() {
$entity->{$field_1_name}->value = 'Test';
$entity->{$field_2_name}->value = 42;
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
// Verify metadata for field 1.
$items_1 = $entity->get($field_1_name);
......@@ -159,7 +159,7 @@ public function testEditorWithCustomMetadata() {
$entity->{$field_name}->value = 'Test';
$entity->{$field_name}->format = 'full_html';
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
// Verify metadata.
$items = $entity->get($field_name);
......
......@@ -2,6 +2,7 @@
namespace Drupal\simpletest\Tests;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\simpletest\WebTestBase;
/**
......@@ -25,9 +26,9 @@ class SimpleTestInstallBatchTest extends WebTestBase {
* Tests loading entities created in a batch in simpletest_test_install().
*/
public function testLoadingEntitiesCreatedInBatch() {
$entity1 = entity_load('entity_test', 1);
$entity1 = EntityTest::load(1);
$this->assertNotNull($entity1, 'Successfully loaded entity 1.');
$entity2 = entity_load('entity_test', 2);
$entity2 = EntityTest::load(2);
$this->assertNotNull($entity2, 'Successfully loaded entity 2.');
}
......
......@@ -320,7 +320,11 @@ function entity_test_form_node_form_alter(&$form, FormStateInterface $form_state
* The loaded entity object, or NULL if the entity cannot be loaded.
*/
function entity_test_load($id, $reset = FALSE) {
return entity_load('entity_test', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
......@@ -335,7 +339,11 @@ function entity_test_load($id, $reset = FALSE) {
* The loaded entity object, or NULL if the entity cannot be loaded.
*/
function entity_test_rev_load($id, $reset = FALSE) {
return entity_load('entity_test_rev', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test_rev');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
......@@ -350,7 +358,11 @@ function entity_test_rev_load($id, $reset = FALSE) {
* The loaded entity object, or FALSE if the entity cannot be loaded.
*/
function entity_test_mul_load($id, $reset = FALSE) {
return entity_load('entity_test_mul', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test_mul');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
......@@ -365,7 +377,11 @@ function entity_test_mul_load($id, $reset = FALSE) {
* The loaded entity object, or NULL if the entity cannot be loaded.
*/
function entity_test_mulrev_load($id, $reset = FALSE) {
return entity_load('entity_test_mulrev', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test_mulrev');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
......
......@@ -52,7 +52,7 @@ public function testTestItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_test instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_test->value, $value);
......@@ -65,7 +65,7 @@ public function testTestItem() {
// Read changed entity and assert changed values.
$entity->save();
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$this->assertEqual($entity->field_test->value, $new_value);
// Test sample item generation.
......
......@@ -195,7 +195,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
// Display the entity.
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent($renderer->renderRoot($content));
......@@ -234,7 +234,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
// Display the entity.
$this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
$entity = entity_load('entity_test', $id);
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent($renderer->renderRoot($content));
......
......@@ -247,7 +247,7 @@ function testEntityQuery() {
->condition("$greetings.value", 'merhaba')
->sort('id')
->execute();
$entities = entity_load_multiple('entity_test_mulrev', $ids);
$entities = EntityTestMulRev::loadMultiple($ids);
$first_entity = reset($entities);
$old_name = $first_entity->name->value;
foreach ($entities as $entity) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment