1
0
mirror of https://github.com/splitbrain/php-archive.git synced 2025-01-29 11:43:06 +01:00

added gzip test, ignored nbproject

This commit is contained in:
Owen 2017-06-10 12:04:06 +08:00
parent 6b1c1746fa
commit b74df7c9ce
2 changed files with 36 additions and 1 deletions

2
.gitignore vendored
View File

@ -5,4 +5,4 @@ vendor/
composer.lock
apigen.phar
docs/
nbproject/

View File

@ -556,6 +556,41 @@ class Tar_TestCase extends PHPUnit_Framework_TestCase
$this->assertEquals(512 * 4, strlen($file)); // 1 header block + data block + 2 footer blocks
}
/**
* @depends test_ext_zlib
*/
public function test_gzipisvalid()
{
foreach (['tgz', 'tar.gz'] as $ext) {
$input = glob(dirname(__FILE__) . '/../src/*');
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.' . $ext;
$extract = sys_get_temp_dir() . '/dwtartest' . md5(time() + 1);
$tar = new Tar();
$tar->setCompression(9, Tar::COMPRESS_GZIP);
$tar->create();
foreach ($input as $path) {
$file = basename($path);
$tar->addFile($path, $file);
}
$tar->save($archive);
$this->assertFileExists($archive);
try {
$phar = new PharData($archive);
$phar->extractTo($extract);
} catch (\Exception $e) {};
$this->assertFileExists("$extract/Tar.php");
$this->assertFileExists("$extract/Zip.php");
$this->nativeCheck($archive, $ext);
self::rdelete($extract);
unlink($archive);
}
}
/**
* recursive rmdir()/unlink()