public function EntityMetadataTestCase::testDataStructureWrapper in Entity API 7
Tests using a data structure with passed in metadata.
File
- ./entity.test, line 1038 
- Entity CRUD API tests.
Class
- EntityMetadataTestCase
- Tests metadata wrappers.
Code
public function testDataStructureWrapper() {
  $log_entry = array(
    'type' => 'entity',
    'message' => $this
      ->randomName(8),
    'variables' => array(),
    'severity' => WATCHDOG_NOTICE,
    'link' => '',
    'user' => $GLOBALS['user'],
  );
  $info['property info'] = array(
    'type' => array(
      'type' => 'text',
      'label' => 'The category to which this message belongs.',
    ),
    'message' => array(
      'type' => 'text',
      'label' => 'The log message.',
    ),
    'user' => array(
      'type' => 'user',
      'label' => 'The user causing the log entry.',
    ),
  );
  $wrapper = entity_metadata_wrapper('log_entry', $log_entry, $info);
  $this
    ->assertEqual($wrapper->user->name
    ->value(), $GLOBALS['user']->name, 'Wrapped custom entity.');
}