Ensures entity access is properly working.
function testEntityAccess() {
// Set up a non-admin user that is allowed to view test entities.
$user = $this
->drupalCreateUser(array(
'view test entity',
));
$this
->drupalLogin($user);
$entity = entity_create('entity_test', array(
'name' => 'test',
));
$entity
->save();
// The current user is allowed to view, create, update and delete entities.
$this
->assertEntityAccess(array(
'create' => TRUE,
'update' => TRUE,
'delete' => TRUE,
'view' => TRUE,
), $entity);
// The custom user is not allowed to view test entities.
$custom_user = $this
->drupalCreateUser();
$this
->assertEntityAccess(array(
'create' => TRUE,
'update' => TRUE,
'delete' => TRUE,
'view' => FALSE,
), $entity, $custom_user);
}