Creates a basic test_entity entity.
function field_test_create_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $label = '') {
$entity = entity_create('test_entity', array(
'fttype' => $bundle,
));
// Only set id and vid properties if they don't come as NULL (creation form).
if (isset($id)) {
$entity->ftid = $id;
}
if (isset($vid)) {
$entity->ftvid = $vid;
// Flag to make sure that the provided vid is used for a new revision.
$entity->use_provided_revision_id = $vid;
}
$label = !empty($label) ? $label : $bundle . ' label';
$entity->ftlabel = $label;
// Make sure the entity will saved even if a primary key is provided.
$entity
->enforceIsNew();
$entity
->setNewRevision();
return $entity;
}