/** * @param array $config * @return \BackupMigrate\Core\Source\FileDirectorySource */ private function newSource($config = array()) { $source = new FileDirectorySource(new Config($config)); $source->setArchiveReader(new \BackupMigrate\Core\Service\TarArchiveReader()); $source->setArchiveWriter(new \BackupMigrate\Core\Service\TarArchiveWriter()); $source->setTempFileManager($this->manager); return $source; }
/** * @covers exportToFile * @covers importFromFile */ public function testBackupRestore() { $file = $this->source->exportToFile(); // Move the file to the tmp directory so we can use command line untar. $tarball = tempnam('/tmp', 'bamtest'); copy($file->realpath(), $tarball); // Untar the file and see if all of the files are there. $this->_compareTarballToFilelist($this->file_list['files'], $tarball); // Restore to another directory. $source = new FileDirectorySource(new Config(['directory' => 'vfs://root/restore/'])); $source->setArchiveWriter(new \BackupMigrate\Core\Service\TarArchiveWriter()); $source->setArchiveReader(new \BackupMigrate\Core\Service\TarArchiveReader()); $source->setTempFileManager($this->manager); $source->importFromFile($file); $result = vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure(); $this->assertEquals($this->file_list['files'], $result['root']['restore']); // Clean up unlink($tarball); }