public function testZipSingleFolder() { mkdir('extracted'); $this->assertTrue(Compression::zip('hiDir', 'hi.zip')); $this->assertTrue(file_exists('hi.zip')); $this->assertFalse(file_exists('extracted/hi.txt')); $this->assertFalse(file_exists('extracted/hiDir')); $this->assertTrue(Compression::unzip('hi.zip', 'extracted')); $this->assertTrue(file_exists('extracted/hi.txt')); $this->assertFalse(file_exists('extracted/hiDir/hi.txt')); unlink('hi.zip'); unlink('extracted/hi.txt'); rmdir('extracted'); }
/** * Packs contents of output folder into ZIP archive. * @return mixed path (string) of ZIP archive with packed output, or null if * no output files were created during plugin execution */ private function packOutput() { $outputFile = null; if ($this->outputFolder != null && is_dir($this->outputFolder) && count(glob($this->outputFolder . DIRECTORY_SEPARATOR . '*')) > 0) { $outputFile = tempnam(sys_get_temp_dir(), ''); if (!Compression::zip($this->outputFolder, $outputFile)) { $outputFile = null; } } return $outputFile; }