protected function BulkDeleteTest::convertToPartialEntities

Converts the passed entities to partially created ones.

This replicates the partial entities created in field_purge_data_batch(), which only have the ids and the to be deleted field defined.

Parameters

$entities: An array of entities of type test_entity.

$field_name: A field name whose data should be copied from $entities into the returned partial entities.

Return value

An array of partial entities corresponding to $entities.

2 calls to BulkDeleteTest::convertToPartialEntities()
BulkDeleteTest::testPurgeField in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that fields are preserved and purged correctly as multiple instances are deleted and purged.
BulkDeleteTest::testPurgeInstance in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that field data items and instances are purged when an instance is deleted.

File

drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php, line 46
Definition of Drupal\field\Tests\BulkDeleteTest.

Class

BulkDeleteTest
Unit test class for field bulk delete and batch purge functionality.

Namespace

Drupal\field\Tests

Code

protected function convertToPartialEntities($entities, $field_name) {
  $partial_entities = array();
  foreach ($entities as $id => $entity) {

    // Re-create the entity to match what is expected
    // _field_create_entity_from_ids().
    $ids = (object) array(
      'entity_id' => $entity->ftid,
      'revision_id' => $entity->ftvid,
      'bundle' => $entity->fttype,
      'entity_type' => 'test_entity',
    );
    $partial_entities[$id] = _field_create_entity_from_ids($ids);
    $partial_entities[$id]->{$field_name} = $entity->{$field_name};
  }
  return $partial_entities;
}