/** * Test Cleanup handling. */ public function testCleanup() { $cleanup = new Configuration\Backup\Cleanup('capacity', false); $backup = new Backup('name'); $backup->cleanupAdd($cleanup); $backup->cleanupFailed($cleanup); $backup->cleanupSkipped($cleanup); $this->assertEquals(1, $backup->cleanupCountFailed()); $this->assertEquals(1, $backup->cleanupCountSkipped()); $this->assertEquals(1, $backup->cleanupCount()); }
/** * Cleanup failed event. * * @param \phpbu\App\Configuration\Backup\Cleanup $cleanup */ public function cleanupFailed(Configuration\Backup\Cleanup $cleanup) { $this->cleanupsFailed++; $this->backupActive->cleanupFailed($cleanup); $event = new Event\Cleanup\Failed($cleanup); $this->eventDispatcher->dispatch(Event\Cleanup\Failed::NAME, $event); }
/** * Prints verbose backup information. * * @param \phpbu\App\Result\Backup $backup */ protected function printBackupVerbose(Result\Backup $backup) { $this->write(sprintf('backup %s: ', $backup->getName())); if ($backup->allOk()) { $this->writeWithColor('fg-black, bg-green', 'OK'); } elseif ($backup->okButSkipsOrFails()) { $this->writeWithColor('fg-black, bg-yellow', 'OK, but skipped or failed Crypts, Syncs or Cleanups!'); } else { $this->writeWithColor('fg-white, bg-red, bold', 'FAILED'); } $chExecuted = str_pad($backup->checkCount(), 8, ' ', STR_PAD_LEFT); $chFailed = str_pad($backup->checkCountFailed(), 6, ' ', STR_PAD_LEFT); $crExecuted = str_pad($backup->cryptCount(), 8, ' ', STR_PAD_LEFT); $crSkipped = str_pad($backup->cryptCountSkipped(), 7, ' ', STR_PAD_LEFT); $crFailed = str_pad($backup->cryptCountFailed(), 6, ' ', STR_PAD_LEFT); $syExecuted = str_pad($backup->syncCount(), 8, ' ', STR_PAD_LEFT); $sySkipped = str_pad($backup->syncCountSkipped(), 7, ' ', STR_PAD_LEFT); $syFailed = str_pad($backup->syncCountFailed(), 6, ' ', STR_PAD_LEFT); $clExecuted = str_pad($backup->cleanupCount(), 8, ' ', STR_PAD_LEFT); $clSkipped = str_pad($backup->cleanupCountSkipped(), 7, ' ', STR_PAD_LEFT); $clFailed = str_pad($backup->cleanupCountFailed(), 6, ' ', STR_PAD_LEFT); $out = PHP_EOL . ' | executed | skipped | failed |' . PHP_EOL . '----------+----------+---------+--------+' . PHP_EOL . ' checks | ' . $chExecuted . ' | | ' . $chFailed . ' |' . PHP_EOL . ' crypts | ' . $crExecuted . ' | ' . $crSkipped . ' | ' . $crFailed . ' |' . PHP_EOL . ' syncs | ' . $syExecuted . ' | ' . $sySkipped . ' | ' . $syFailed . ' |' . PHP_EOL . ' cleanups | ' . $clExecuted . ' | ' . $clSkipped . ' | ' . $clFailed . ' |' . PHP_EOL . '----------+----------+---------+--------+' . PHP_EOL . PHP_EOL; $this->write($out); }