1
0
mirror of https://github.com/splitbrain/php-archive.git synced 2025-01-17 13:38:26 +01:00

added dogfooding test, extract self created archives

This commit is contained in:
Andreas Gohr 2015-08-12 15:24:34 +02:00
parent c2490eaadc
commit c075304b44
2 changed files with 34 additions and 1 deletions

View File

@ -158,7 +158,8 @@ class Tar_TestCase extends PHPUnit_Framework_TestCase
/**
* Create an archive and unpack it again
*/
public function test_dogfood() {
public function test_dogfood()
{
foreach ($this->extensions as $ext) {
$input = glob(dirname(__FILE__) . '/../src/*');
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.' . $ext;

View File

@ -118,6 +118,38 @@ class Zip_TestCase extends PHPUnit_Framework_TestCase
$this->assertEquals(13, $content[4]->getSize(), "Contents of $file");
}
/**
* Create an archive and unpack it again
*/
public function test_dogfood()
{
$input = glob(dirname(__FILE__) . '/../src/*');
$archive = sys_get_temp_dir() . '/dwziptest' . md5(time()) . '.zip';
$extract = sys_get_temp_dir() . '/dwziptest' . md5(time() + 1);
$zip = new Zip();
$zip->create($archive);
foreach($input as $path) {
$file = basename($path);
$zip->addFile($path, $file);
}
$zip->close();
$this->assertFileExists($archive);
$zip = new Zip();
$zip->open($archive);
$zip->extract($extract, '', '/FileInfo\\.php/', '/.*\\.php/');
$this->assertFileExists("$extract/Tar.php");
$this->assertFileExists("$extract/Zip.php");
$this->assertFileNotExists("$extract/FileInfo.php");
self::rdelete($extract);
unlink($archive);
}
/**
* Extract the prebuilt zip files
*/