$entity_init =
$this->container->
get('entity_type.manager'
) ->
getStorage($entity_type) ->
create(['type' =>
$entity_type]);
$cardinality =
$this->fieldTestData->field_storage_2->
getCardinality();
$this->
assertFalse($this->fieldTestData->field_storage_2->
hasData(), 'There are no entities with field data.'
);
$this->
assertSame(0,
$this->storageRev->
countFieldData($this->fieldTestData->field_storage_2
), 'There are 0 entities with field data.'
);
// Create 1 entity with the field.
$entity =
clone($entity_init);
$values =
$this->
_generateTestFieldValues($this->fieldTestData->field_storage_2->
getCardinality());
$entity->
{$this->fieldTestData->field_name_2
} =
$values;
$entity->
setNewRevision();
$entity->
save();
$first_revision =
$entity->
getRevisionId();
$this->
assertTrue($this->fieldTestData->field_storage_2->
hasData(), 'There are entities with field data.'
);
$this->
assertSame(1,
$this->storageRev->
countFieldData($this->fieldTestData->field_storage_2
), 'There is 1 entity with field data.'
);
$entity->
{$this->fieldTestData->field_name_2
} =
[];
$entity->
setNewRevision();
$entity->
save();