drupal 7 entity and simple test
Try the examples module: 


  This project aims to provide high-quality, well-documented API
  examples for a broad range of Drupal core functionality.
  
  The Examples project contains many modules which hopefully illustrate
  best practices for implementing various Drupal APIs. These modules can
  be enabled individually, and will typically add menu items to your
  site, which should guide you through their features. You can then look
  through the code to see what they are doing.


It has a drupal 7 &amp; 8 entity example in which has a test as well.