You are here

class BackupMigrateDestinationFake in Backup and migrate prune 7

Same name and namespace in other branches
  1. 7.2 backup_migrate_prune.test \BackupMigrateDestinationFake

Fake destination for test purposes

Hierarchy

Expanded class hierarchy of BackupMigrateDestinationFake

1 string reference to 'BackupMigrateDestinationFake'
BackupMigrateDestinationFake::list_files in ./backup_migrate_prune.test
Overwrites list_files to return a fake list of files

File

./backup_migrate_prune.test, line 127
Test implementation file

View source
class BackupMigrateDestinationFake extends backup_migrate_destination {

  /**
   * Overwrites list_files to return a fake list of files
   */
  public function list_files() {
    $files = array();
    $datetime = new \DateTime(BackupMigratePruneTestCase::DATEINIT, new \DateTimeZone('Europe/Berlin'));
    $datetime_end = new \DateTime(BackupMigratePruneTestCase::DATEEND, new \DateTimeZone('Europe/Berlin'));
    $interval = new \DateInterval(BackupMigratePruneTestCase::TIMEINTERVAL);
    do {
      $timestamp = $datetime
        ->getTimestamp();
      $filename = "BackupMigratePruneTest-" . $datetime
        ->format("Y-m-d\\TH-i-s") . '.mysql.gz';
      global $base_url;
      $file_info = array(
        'filename' => $filename,
        'description' => '',
        'datestamp' => $timestamp,
        'generator' => 'BackupMigrateDestinationFake',
        'generatorversion' => '7.x-1.x',
        'sites' => array(
          array(
            'version' => VERSION,
            'name' => 'BackupMigrateDestinationTest',
            'url' => $base_url,
          ),
        ),
        'filesize' => mt_rand(1024, 4096),
        'filetime' => $timestamp,
      );
      $file = new BackupFileFake();
      $file
        ->set_file_info($file_info);
      $files[$filename] = $file;
      $datetime
        ->add($interval);
    } while ($datetime < $datetime_end);
    return $files;
  }

  /**
   * Overwrites delete_file to do nothing (fake files are not deletable)
   */
  public function delete_file() {
    return NULL;
  }

  /**
   * Overwrites op to support fake deletions
   */
  public function op($operation) {
    if ($operation == 'delete') {
      return TRUE;
    }
    return parent::op($operation);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BackupMigrateDestinationFake::delete_file public function Overwrites delete_file to do nothing (fake files are not deletable)
BackupMigrateDestinationFake::list_files public function Overwrites list_files to return a fake list of files
BackupMigrateDestinationFake::op public function Overwrites op to support fake deletions