Creates a test entity.
\Drupal\Core\Entity\EntityInterface
protected function createTestEntity($entity_type) {
$this->entity_name = $this
->randomName();
$this->entity_user = $this
->createUser();
$this->entity_field_text = $this
->randomName();
// Pass in the value of the name field when creating. With the user
// field we test setting a field after creation.
$entity = entity_create($entity_type, array());
$entity->user_id->target_id = $this->entity_user->uid;
$entity->name->value = $this->entity_name;
// Set a value for the test field.
$entity->field_test_text->value = $this->entity_field_text;
return $entity;
}