You are here

protected function FieldUnitTestBase::entitySaveReload in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/FieldUnitTestBase.php \Drupal\field\Tests\FieldUnitTestBase::entitySaveReload()

Saves and reloads an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to save.

Return value

\Drupal\Core\Entity\EntityInterface The entity, freshly reloaded from storage.

8 calls to FieldUnitTestBase::entitySaveReload()
FieldAttachOtherTest::testEntityCache in core/modules/field/src/Tests/FieldAttachOtherTest.php
Test entity cache.
FieldAttachStorageTest::testEntityCreateBundle in core/modules/field/src/Tests/FieldAttachStorageTest.php
Test entity_bundle_create().
FieldAttachStorageTest::testEntityDeleteBundle in core/modules/field/src/Tests/FieldAttachStorageTest.php
Test entity_bundle_delete().
FieldAttachStorageTest::testFieldAttachSaveEmptyData in core/modules/field/src/Tests/FieldAttachStorageTest.php
Tests insert and update with empty or NULL fields.
FieldAttachStorageTest::testFieldAttachSaveEmptyDataDefaultValue in core/modules/field/src/Tests/FieldAttachStorageTest.php
Test insert with empty or NULL fields, with default value.

... See full list

File

core/modules/field/src/Tests/FieldUnitTestBase.php, line 133
Contains \Drupal\field\Tests\FieldUnitTestBase.

Class

FieldUnitTestBase
Parent class for Field API unit tests.

Namespace

Drupal\field\Tests

Code

protected function entitySaveReload(EntityInterface $entity) {
  $entity
    ->save();
  $controller = $this->container
    ->get('entity.manager')
    ->getStorage($entity
    ->getEntityTypeId());
  $controller
    ->resetCache();
  return $controller
    ->load($entity
    ->id());
}