You are here

public function BackupMigratePruneTestCase::testGardenerArrangeFiles in Backup and migrate prune 7

Same name and namespace in other branches
  1. 7.2 backup_migrate_prune.test \BackupMigratePruneTestCase::testGardenerArrangeFiles()

Test Gardener::arrangeFiles() method

See also

Gardener::arrangeFiles()

File

./backup_migrate_prune.test, line 40
Test implementation file

Class

BackupMigratePruneTestCase
BackupMigratePruneTestCase class for unit testing

Code

public function testGardenerArrangeFiles() {
  $gardener = new GardenerFake();
  $gardener
    ->setDateReference(BackupMigratePruneTestCase::DATEEND);
  $files = $gardener
    ->arrangeFiles();
  $this
    ->assertEqual(count($files), 4, 'There are 4 time slots.');
  foreach ($files as $time_slot => $fileset) {
    switch ($time_slot) {
      case 'thisweek_slot':
        $this
          ->assertEqual(count($fileset), 6, 'There are 6 days (7 minus today) with backups this week.');
        break;
      case 'thismonth_slot':
        $this
          ->assertTrue(count($fileset) >= 3, 'There are at least 3 weeks (4 minus current) with backups this month.');
        break;
      case 'thisyear_slot':
        $this
          ->assertEqual(count($fileset), 11, 'There are 11 months (12 minus today) with backups this year.');
        break;
      case 'pastyears_slot':
        $this
          ->assertTrue(count($fileset) > 0, 'There is at least one past year with backups.');
        break;
      default:
        $this
          ->fail('Unexpected time slot: ' . $time_slot);
        break;
    }
  }
}