You are here

function BackupMigrateFunctionalityTest::testSaveDefaultSettings in Backup and Migrate 5

File

tests/BackupMigrateFunctionalityTest.test, line 91

Class

BackupMigrateFunctionalityTest
Unit tests for Backup and Migrate module.

Code

function testSaveDefaultSettings() {
  $directory = _backup_migrate_get_save_path();
  $tables = _backup_migrate_get_table_names();
  $edit = array(
    'backup_migrate_file_name' => $this
      ->randomName(5, 'backup'),
    'backup_migrate_exclude_tables[]' => $tables,
    'backup_migrate_nodata_tables[]' => $tables,
    'backup_migrate_compression' => "gzip",
    'backup_migrate_timestamp_format' => 'Y-m-d',
    'backup_migrate_destination' => "download",
    'backup_migrate_append_timestamp' => false,
    'backup_migrate_save_settings' => true,
  );
  foreach ($edit as $key => $value) {
    $this
      ->drupalVariableSet($key, NULL);
  }
  $this
    ->drupalLoginUser($this->admin_user);
  $this
    ->drupalPostRequest("admin/content/backup_migrate", $edit, t('Backup Database'));

  // load vars from db (becuase they were saved by a seperate thread, they are not available to variable_get)
  $vars = variable_init();
  unset($edit['backup_migrate_save_settings']);
  foreach ($edit as $key => $value) {
    $key = str_replace("[]", '', $key);
    $this
      ->assertEqual($vars[$key], $value, t('Checking that the variable !var was set', array(
      '!var' => $key,
    )));
  }
  $this
    ->drupalGet(url("logout", NULL, NULL, TRUE));
  $this
    ->delete_directory($directory);
}