You are here

protected function DefaultFieldComparatorWebTestCase::setUp in Changed Fields API 7.3

Same name and namespace in other branches
  1. 7.2 tests/default_field_comparator.test \DefaultFieldComparatorWebTestCase::setUp()

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

tests/default_field_comparator.test, line 29
Test default field comparator.

Class

DefaultFieldComparatorWebTestCase
Class DefaultFieldComparatorWebTestCase.

Code

protected function setUp() {
  parent::setUp([
    'changed_fields_basic_usage',
  ]);

  // Create additional fields for article content type.
  $fields = [
    'text' => [
      'base' => [
        'field_name' => 'field_text_test',
        'type' => 'text',
        'cardinality' => -1,
      ],
      'instance' => [
        'field_name' => 'field_text_test',
        'entity_type' => 'node',
        'label' => 'Text field',
        'bundle' => 'article',
      ],
    ],
    'file' => [
      'base' => [
        'field_name' => 'field_file_test',
        'type' => 'file',
      ],
      'instance' => [
        'field_name' => 'field_file_test',
        'entity_type' => 'node',
        'label' => 'File',
        'bundle' => 'article',
        'settings' => [
          'description_field' => TRUE,
          'display_field' => TRUE,
        ],
      ],
    ],
    'image' => [
      'base' => [
        'field_name' => 'field_image_test',
        'type' => 'image',
      ],
      'instance' => [
        'field_name' => 'field_image_test',
        'entity_type' => 'node',
        'label' => 'Image',
        'bundle' => 'article',
        'settings' => [
          'alt_field' => TRUE,
          'title_field' => TRUE,
        ],
      ],
    ],
  ];
  foreach ($fields as $field) {
    field_create_field($field['base']);
    field_create_instance($field['instance']);
  }
}