You are here

public function viewsHandlerFieldFieldTest::setUp in Views (for Drupal 7) 7.3

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 ViewsSqlTest::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

tests/field/views_fieldapi.test, line 294
Tests the fieldapi integration of viewsdata.

Class

viewsHandlerFieldFieldTest
Tests the field_field handler.

Code

public function setUp(array $modules = array()) {
  parent::setUp($modules);

  // Setup basic fields.
  $this
    ->setUpFields(3);

  // Setup a field with cardinality > 1.
  $this->fields[3] = $field = field_create_field(array(
    'field_name' => 'field_name_3',
    'type' => 'text',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  ));

  // Setup a field that will have no value.
  $this->fields[4] = $field = field_create_field(array(
    'field_name' => 'field_name_4',
    'type' => 'text',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  ));
  $this
    ->setUpInstances();
  $this
    ->clearViewsCaches();

  // Create some nodes.
  $this->nodes = array();
  for ($i = 0; $i < 3; $i++) {
    $edit = array(
      'type' => 'page',
    );
    for ($key = 0; $key < 3; $key++) {
      $field = $this->fields[$key];
      $edit[$field['field_name']][LANGUAGE_NONE][0]['value'] = $this
        ->randomName(8);
    }
    for ($j = 0; $j < 5; $j++) {
      $edit[$this->fields[3]['field_name']][LANGUAGE_NONE][$j]['value'] = $this
        ->randomName(8);
    }

    // Set this field to be empty.
    $edit[$this->fields[4]['field_name']] = array();
    $this->nodes[$i] = $this
      ->drupalCreateNode($edit);
  }
}