Skip to content

Commit b74df7c

Browse files
author
Owen
committed
added gzip test, ignored nbproject
1 parent 6b1c174 commit b74df7c

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ vendor/
55
composer.lock
66
apigen.phar
77
docs/
8-
8+
nbproject/

tests/tar.test.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,41 @@ public function test_blockdata()
556556

557557
$this->assertEquals(512 * 4, strlen($file)); // 1 header block + data block + 2 footer blocks
558558
}
559+
560+
/**
561+
* @depends test_ext_zlib
562+
*/
563+
public function test_gzipisvalid()
564+
{
565+
foreach (['tgz', 'tar.gz'] as $ext) {
566+
$input = glob(dirname(__FILE__) . '/../src/*');
567+
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.' . $ext;
568+
$extract = sys_get_temp_dir() . '/dwtartest' . md5(time() + 1);
569+
570+
$tar = new Tar();
571+
$tar->setCompression(9, Tar::COMPRESS_GZIP);
572+
$tar->create();
573+
foreach ($input as $path) {
574+
$file = basename($path);
575+
$tar->addFile($path, $file);
576+
}
577+
$tar->save($archive);
578+
$this->assertFileExists($archive);
579+
580+
try {
581+
$phar = new PharData($archive);
582+
$phar->extractTo($extract);
583+
} catch (\Exception $e) {};
584+
585+
$this->assertFileExists("$extract/Tar.php");
586+
$this->assertFileExists("$extract/Zip.php");
587+
588+
$this->nativeCheck($archive, $ext);
589+
590+
self::rdelete($extract);
591+
unlink($archive);
592+
}
593+
}
559594

560595
/**
561596
* recursive rmdir()/unlink()

0 commit comments

Comments
 (0)