1 field_views.test protected FieldViewsFieldTest::setUp()

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

Generates a random database prefix and installs Backdrop with the specified installation profile in BackdropWebTestCase::$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.

Return value

bool: TRUE if set up completes, FALSE if an error occurred.

Overrides ViewsSqlTest::setUp

See also

BackdropWebTestCase::prepareDatabasePrefix()

BackdropWebTestCase::changeDatabasePrefix()

BackdropWebTestCase::prepareEnvironment()

File

core/modules/field/tests/field_views.test, line 275
Tests the Views integration with Field API.

Class

FieldViewsFieldTest
Tests the field_field handler. @TODO Check a entity-type with bundles Check a entity-type without bundles Check locale:disabled, locale:enabled and locale:enabled with another language Check revisions

Code

protected function setUp() {
  parent::setUp();

  // Setup basic fields. When field render is tested in these tests with
  // $view->style_plugin->get_field() the loop counter will need to be
  // incremented by two each time to account for the two existing welcome
  // nodes in the standard install profile.
  $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->backdropCreateNode($edit);
  }
}