// Verify that all data got deleted.
$definition = \Drupal::
entityTypeManager()->
getDefinition($entity_type);
$connection = Database::
getConnection();
$this->
assertEquals(0,
(int) $connection->
select($definition->
getBaseTable())->
countQuery()->
execute()->
fetchField(), 'Base table was emptied'
);
if ($data_table =
$definition->
getDataTable()) { $this->
assertEquals(0,
(int) $connection->
select($data_table)->
countQuery()->
execute()->
fetchField(), 'Data table was emptied'
);
} if ($revision_table =
$definition->
getRevisionTable()) { $this->
assertEquals(0,
(int) $connection->
select($revision_table)->
countQuery()->
execute()->
fetchField(), 'Revision table was emptied'
);
} if ($revision_data_table =
$definition->
getRevisionDataTable()) { $this->
assertEquals(0,
(int) $connection->
select($revision_data_table)->
countQuery()->
execute()->
fetchField(), 'Revision data table was emptied'
);
} // Test deleting a list of entities not indexed by entity id.
$entities =
[];
$entity =
$storage->
create(['name' => 'test', 'user_id' =>
$user1->
id()]);
$entity->
save();
$entities['test'
] =
$entity;
$entity =
$storage->
create(['name' => 'test2', 'user_id' =>
$user1->
id()]);
$entity->
save();
$entities['test2'
] =
$entity;