You are here

protected function FieldKernelTestBase::entitySaveReload in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/FieldKernelTestBase.php \Drupal\Tests\field\Kernel\FieldKernelTestBase::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 FieldKernelTestBase::entitySaveReload()
FieldAttachOtherTest::testEntityCache in core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php
Test entity cache.
FieldAttachStorageTest::testEntityCreateBundle in core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
Test entity_bundle_create().
FieldAttachStorageTest::testEntityDeleteBundle in core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
Test entity_bundle_delete().
FieldAttachStorageTest::testFieldAttachSaveEmptyData in core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
Tests insert and update with empty or NULL fields.
FieldAttachStorageTest::testFieldAttachSaveEmptyDataDefaultValue in core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
Test insert with empty or NULL fields, with default value.

... See full list

File

core/modules/field/tests/src/Kernel/FieldKernelTestBase.php, line 138

Class

FieldKernelTestBase
Parent class for Field API unit tests.

Namespace

Drupal\Tests\field\Kernel

Code

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