/** @test */ public function parseShouldReturnString() { $filename = new Filename(); $parsed = $filename->parse(); $hash = md5(__DIR__ . ' ' . __FILE__); $date = date('N'); $this->assertEquals($hash . '.' . $date . '.zip', $parsed); }
/** * @param string $tempPath * @return bool * @throws \Astrotomic\Backuplay\Exceptions\FileDoesNotExistException */ protected function storeArchive($tempPath) { $disk = $this->config->get('disk'); if ($disk === false) { $this->warn('storage is disabled'); return false; } $this->comment('store archive on disk: ' . $disk); $filename = new Filename(); foreach ($this->config->get('storage_cycle', []) as $cycle) { $this->comment('put ' . $cycle . ' archive in storage'); $filePath = implode(DIRECTORY_SEPARATOR, array_filter([$this->config->get('storage_path'), $filename->cycleParse($cycle)])); $content = file_get_contents($tempPath); Event::fire(new BackupCreateBeforeStore($this, $cycle, $filePath, $content)); Storage::disk($disk)->put($filePath, $content); if (!Storage::disk($disk)->exists($filePath)) { Event::fire(new BackupCreateFailedStore($this, $cycle, $filePath, $content)); throw new FileDoesNotExistException($filePath); } $this->info($cycle . ' archive stored'); Event::fire(new BackupCreateAfterStore($this, $cycle, $filePath, $content)); } $this->unlink($tempPath); return true; }