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