You are here

function TMGMTUpgradeAlpha1TestCase::setUp in Translation Management Tool 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

tests/tmgmt.upgrade.alpha1.test, line 23

Class

TMGMTUpgradeAlpha1TestCase
Upgrade tests.

Code

function setUp() {

  // Enable all dependencies.
  parent::setUp(array(
    'entity',
    'views',
    'translation',
    'locale',
  ));
  $this
    ->pass('Test disabled due to https://www.drupal.org/project/drupalci_testbot/issues/2971824.');
  return;

  // Create the tmgmt tables and fill them.
  module_load_include('inc', 'tmgmt', 'tests/tmgmt_alpha1_dump.sql');

  // @todo: Figure out why this is necessary.
  $enabled_modules = db_query("SELECT name FROM {system} where status = 1 and type = 'module'")
    ->fetchCol();
  foreach ($enabled_modules as $enabled_module) {
    module_load_install($enabled_module);

    // Set the schema version to the number of the last update provided
    // by the module.
    $versions = drupal_get_schema_versions($enabled_module);
    $version = $versions ? max($versions) : SCHEMA_INSTALLED;
    db_update('system')
      ->condition('name', $enabled_module)
      ->fields(array(
      'schema_version' => $version,
    ))
      ->execute();
  }

  // Set schema version to 0 and then install the tmgmt modules, to simulate
  // an enabling.
  db_update('system')
    ->condition('name', array(
    'tmgmt',
    'tmgmt_ui',
    'tmgmt_field',
    'tmgmt_node',
    'tmgmt_test',
    'tmgmt_node_ui',
  ))
    ->fields(array(
    'schema_version' => 0,
  ))
    ->execute();
  module_enable(array(
    'tmgmt',
    'tmgmt_ui',
    'tmgmt_field',
    'tmgmt_node',
    'tmgmt_test',
    'tmgmt_node_ui',
  ));

  // Log in as a user that can run update.php
  $admin = $this
    ->drupalCreateUser(array(
    'administer software updates',
  ));
  $this
    ->drupalLogin($admin);
  $this
    ->performUpgrade();
}