示例#1
0
 /**
  * Execute the cleanup.
  *
  * @param  \phpbu\App\Configuration\Backup $backup
  * @param  \phpbu\App\Backup\Target        $target
  * @param  \phpbu\App\Backup\Collector     $collector
  * @throws \Exception
  */
 protected function executeCleanup(Configuration\Backup $backup, Target $target, Collector $collector)
 {
     $cleanup = $backup->getCleanup();
     if (!empty($cleanup)) {
         try {
             $this->result->cleanupStart($cleanup);
             if ($this->failure && $cleanup->skipOnFailure) {
                 $this->result->cleanupSkipped($cleanup);
             } else {
                 $cleaner = $this->factory->createCleaner($cleanup->type, $cleanup->options);
                 $cleaner->cleanup($target, $collector, $this->result);
                 $this->result->cleanupEnd($cleanup);
             }
         } catch (Backup\Cleaner\Exception $e) {
             $this->failure = true;
             $this->result->addError($e);
             $this->result->cleanupFailed($cleanup);
         }
     }
 }
示例#2
0
 /**
  * Tests Factory::createCleaner
  *
  * @expectedException \phpbu\App\Exception
  */
 public function testCreateCleanerThatIsNone()
 {
     Factory::register('cleaner', 'nothing', '\\phpbu\\App\\phpbuAppFactoryTestNothing', true);
     $factory = new Factory();
     $factory->createCleaner('nothing');
     $this->assertFalse(true, 'Exception should be thrown');
 }