mirror of
https://github.com/splitbrain/php-archive.git
synced 2025-07-12 10:26:27 +02:00
added dogfooding test, extract self created archives
This commit is contained in:
@ -158,7 +158,8 @@ class Tar_TestCase extends PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Create an archive and unpack it again
|
* Create an archive and unpack it again
|
||||||
*/
|
*/
|
||||||
public function test_dogfood() {
|
public function test_dogfood()
|
||||||
|
{
|
||||||
foreach ($this->extensions as $ext) {
|
foreach ($this->extensions as $ext) {
|
||||||
$input = glob(dirname(__FILE__) . '/../src/*');
|
$input = glob(dirname(__FILE__) . '/../src/*');
|
||||||
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.' . $ext;
|
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.' . $ext;
|
||||||
|
@ -118,6 +118,38 @@ class Zip_TestCase extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(13, $content[4]->getSize(), "Contents of $file");
|
$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
|
* Extract the prebuilt zip files
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user