function FieldKernelTestBase::entitySaveReload

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/FieldKernelTestBase.php \Drupal\Tests\field\Kernel\FieldKernelTestBase::entitySaveReload()
  2. 8.9.x core/modules/field/tests/src/Kernel/FieldKernelTestBase.php \Drupal\Tests\field\Kernel\FieldKernelTestBase::entitySaveReload()
  3. 11.x 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
Tests entity cache.
FieldAttachStorageTest::testEntityCreateBundle in core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
Tests entity_bundle_create().
FieldAttachStorageTest::testEntityDeleteBundle in core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
Tests 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
Tests insert with empty or NULL fields, with default value.

... See full list

File

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

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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.