/** * @test */ public function adds_file_to_collection() { $backup = new Backup($this->dropboxInstance(), $this->working); $backup->addJob(new Job(new FileJob($this->css_file(), $this->assets), 'files')); $backup->addJob(new Job(new FileJob($this->terms_file(), $this->assets), 'files')); $backup->prepare(); $backup->processFiles(); $this->assertCount(1, $backup->getCollection(), 'Files are not in the collection'); $this->assertCount(2, $backup->getCollection()['files'], 'There are more or less than 2 items in the "files" item of the collection'); }
/** * Add files from the collection to the archive. * * @return void */ private function processCollection() { foreach ($this->backup->getCollection() as $namespace => $items) { foreach ($items as $item) { if (is_dir($item['path'])) { $this->archive->addEmptyDir($this->namespacedName($namespace, $item)); } else { $this->archive->addFile($item['path'], $this->namespacedName($namespace, $item)); } } } }
/** * @test */ public function cleans_collection() { $backup = new Backup($this->dropboxInstance(), $this->working); $backup->addJob(new Job(new File($this->terms_file(), $this->assets))); $backup->prepare(); $backup->processFiles(); $archive = new Archive($backup, new ZipArchive()); $archive->execute(); $this->assertCount(1, $backup->getCollection(), 'Collection does not contain 1 item'); $this->assertFileExists($backup->archivePath()); $cleanup = new Cleanup($backup); $cleanup->execute(); $this->assertEmpty($backup->getCollection(), 'Collection is not empty'); $this->assertFileNotExists($backup->archivePath()); }
/** * @test */ public function adds_directory_to_collection_with_exclusion() { $backup = new Backup($this->dropboxInstance(), $this->working); $backup->addJob(new Job(new DirectoryJob($this->css_directory(), $this->assets, [$this->css_components_directory()]), 'directories')); $backup->prepare(); $backup->processDirectories(); $this->assertCount(1, $backup->getCollection()['directories'], 'There is more then 1 item in the "directories" collection'); }