You are here

function BackupMigrateUnitTest::testPathinSaveDir in Backup and Migrate 5

File

tests/BackupMigrateUnitTest.test, line 461

Class

BackupMigrateUnitTest
Unit tests for Backup and Migrate module.

Code

function testPathinSaveDir() {

  //
  $directory = _backup_migrate_get_save_path();
  $this
    ->delete_directory(file_directory_path() . "/backup_migrate");

  // should be false if directories don't exist
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir($directory), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir($directory . "/test"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir($directory . "/a/b/c"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir($directory . "/manual", "manual"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir($directory . "manual/a/b/c", "manual"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir($directory . "/scheduled", "scheduled"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir($directory . "scheduled/a/b/c", "scheduled"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test/" . $directory), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test/", "manual"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test/", "scheduled"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("manual", "manual"), t('Checking that non-existant directory returns false'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("scheduled", "scheduled"), t('Checking that non-existant directory returns false'));
  _backup_migrate_check_destination_dir('manual');
  _backup_migrate_check_destination_dir('scheduled');
  $this
    ->assertTrue(_backup_migrate_path_is_in_save_dir($directory), t('Checking that valid path is confirmed'));
  $this
    ->assertTrue(_backup_migrate_path_is_in_save_dir($directory . "/test"), t('Checking that valid path is confirmed'));
  $this
    ->assertTrue(_backup_migrate_path_is_in_save_dir($directory . "/manual", "manual"), t('Checking that valid path is confirmed'));
  $this
    ->assertTrue(_backup_migrate_path_is_in_save_dir($directory . "/scheduled", "scheduled"), t('Checking that valid path is confirmed'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test/" . $directory), t('Checking that invalid path is rejected'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test"), t('Checking that invalid path is rejected'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test/", "manual"), t('Checking that invalid path is rejected'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("test/", "scheduled"), t('Checking that invalid path is rejected'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("manual", "manual"), t('Checking that invalid path is rejected'));
  $this
    ->assertFalse(_backup_migrate_path_is_in_save_dir("scheduled", "scheduled"), t('Checking that invalid path is rejected'));
  $this
    ->delete_directory(file_directory_path() . "/backup_migrate");
}