public function testTgzExtract()
{
$tar = false;
$includePath = explode(PATH_SEPARATOR, get_include_path());
foreach ($includePath as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . 'Archive' . DIRECTORY_SEPARATOR . 'Tar.php')) {
$tar = true;
}
}
if ($tar && function_exists('gzcompress')) {
$a = new Archive(__DIR__ . '/../tmp/test.tar');
$a->addFiles(__DIR__ . '/../tmp');
$a->compress();
chmod(__DIR__ . '/../tmp/test.tar.gz', 0777);
unset($a);
$a = new Archive(__DIR__ . '/../tmp/test.tar.gz');
mkdir(__DIR__ . '/../tmp/test');
chmod(__DIR__ . '/../tmp/test', 0777);
$files = $a->listFiles();
$files = $a->listFiles(true);
$this->assertTrue(is_array($files));
$a->extract(__DIR__ . '/../tmp/test');
$dir = new Dir(__DIR__ . '/../tmp/test');
$this->assertGreaterThan(0, count($dir->getFiles()));
$dir->emptyDir();
rmdir(__DIR__ . '/../tmp/test');
if (file_exists(__DIR__ . '/../tmp/test.tar')) {
unlink(__DIR__ . '/../tmp/test.tar');
}
if (file_exists(__DIR__ . '/../tmp/test.tar.gz')) {
unlink(__DIR__ . '/../tmp/test.tar.gz');
}
}
}