You are here

function WsfieldsStorageTestCase::setUp in Web Service Data 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/wsfields_storage/wsfields_storage.test, line 23
Describe the file

Class

WsfieldsStorageTestCase
@file Describe the file

Code

function setUp() {
  parent::setUp('wsfields_storage', 'ws_services', 'rest_server', 'restclient', 'devel_generate');

  // Note the restclient module is not the one found on Drupal.org. It is the restclient mentioned in the wsdata README file
  $this->admin = $this
    ->drupalCreateUser(array(
    'administer wsconfig types',
    'administer wsconfig',
    'administer site configuration',
    'administer services',
    'administer nodes',
    'administer users',
    'access devel information',
  ));
  $this
    ->drupalLogin($this->admin);

  // Enable test server configuration
  services_endpoint_save(_wsfields_storage_test_endpoint_config());

  // Create and save a wsconfig_type
  wsconfig_type_save(wsconfig_type_create(_wsfields_storage_test_wsconfig_types($this
    ->getAbsoluteUrl('/'))));

  // Create and save a wsconfig instance
  wsconfig_save(wsconfig_create(_wsfields_storage_test_wsconfig()));

  // Create node content using devel_generate
  $settings = array(
    'node_types[article]' => 'article',
    'node_types[page]' => FALSE,
    'time_range' => 1,
    'title_length' => 4,
  );
  $this
    ->drupalPost('admin/config/development/generate/content', $settings, t('Generate'));

  // Create field using wsfields_storage
  foreach (_wsfields_storage_test_field_definitions() as $field) {
    field_create_field($field);
  }

  // Create field instances
  foreach (_wsfields_storage_test_field_instances() as $field_instance) {
    field_create_instance($field_instance);
  }

  // Create users with instances of wsfields using devel_generate
  $settings = array();

  // Generate users
  $this
    ->drupalPost('admin/config/development/generate/user', $settings, t('Generate'));
}