You are here

public function EntityAPITestCase::testRendering in Entity API 7

Tests viewing entities.

File

./entity.test, line 415
Entity CRUD API tests.

Class

EntityAPITestCase
Test basic API.

Code

public function testRendering() {
  module_enable(array(
    'entity_feature',
  ));
  $user1 = $this
    ->drupalCreateUser();

  // Create test entities for the user1 and unrelated to a user.
  $entity = entity_create('entity_test', array(
    'name' => 'test',
    'uid' => $user1->uid,
  ));
  $render = $entity
    ->view();
  $output = drupal_render($render);

  // The entity class adds the user name to the output. Verify it is there.
  $this
    ->assertTrue(strpos($output, format_username($user1)) !== FALSE, 'Entity has been rendered');
}