You are here

function TaxonomyTermFieldMultipleVocabularyTestCase::setUp in Drupal 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

modules/taxonomy/taxonomy.test, line 1632
Tests for taxonomy.module.

Class

TaxonomyTermFieldMultipleVocabularyTestCase
Tests a taxonomy term reference field that allows multiple vocabularies.

Code

function setUp() {
  parent::setUp('field_test');
  $web_user = $this
    ->drupalCreateUser(array(
    'access field_test content',
    'administer field_test content',
    'administer taxonomy',
  ));
  $this
    ->drupalLogin($web_user);
  $this->vocabulary1 = $this
    ->createVocabulary();
  $this->vocabulary2 = $this
    ->createVocabulary();

  // Set up a field and instance.
  $this->field_name = drupal_strtolower($this
    ->randomName());
  $this->field = array(
    'field_name' => $this->field_name,
    'type' => 'taxonomy_term_reference',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
    'settings' => array(
      'allowed_values' => array(
        array(
          'vocabulary' => $this->vocabulary1->machine_name,
          'parent' => '0',
        ),
        array(
          'vocabulary' => $this->vocabulary2->machine_name,
          'parent' => '0',
        ),
      ),
    ),
  );
  field_create_field($this->field);
  $this->instance = array(
    'field_name' => $this->field_name,
    'entity_type' => 'test_entity',
    'bundle' => 'test_bundle',
    'widget' => array(
      'type' => 'options_select',
    ),
    'display' => array(
      'full' => array(
        'type' => 'taxonomy_term_reference_link',
      ),
    ),
  );
  field_create_instance($this->instance);
}