You are here

protected function EntityMetadataTestCase::setUp in Entity API 7

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DrupalWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

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

Class

EntityMetadataTestCase
Tests metadata wrappers.

Code

protected function setUp() {
  parent::setUp('entity', 'entity_test', 'locale');

  // Create a field having 4 values for testing multiple value support.
  $this->field_name = drupal_strtolower($this
    ->randomName() . '_field_name');
  $this->field = array(
    'field_name' => $this->field_name,
    'type' => 'text',
    'cardinality' => 4,
  );
  $this->field = field_create_field($this->field);
  $this->field_id = $this->field['id'];
  $this->instance = array(
    'field_name' => $this->field_name,
    'entity_type' => 'node',
    'bundle' => 'page',
    'label' => $this
      ->randomName() . '_label',
    'description' => $this
      ->randomName() . '_description',
    'weight' => mt_rand(0, 127),
    'settings' => array(
      'text_processing' => FALSE,
    ),
    'widget' => array(
      'type' => 'text_textfield',
      'label' => 'Test Field',
      'settings' => array(
        'size' => 64,
      ),
    ),
  );
  field_create_instance($this->instance);

  // Make the body field and the node type 'page' translatable.
  $field = field_info_field('body');
  $field['translatable'] = TRUE;
  field_update_field($field);
  variable_set('language_content_type_page', 1);
}