1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-08-29 17:59:55 +02:00

Completely rewritten code.

Implement read-only zip file - class \PhpZip\ZipFile, create and update zip file - \PhpZip\ZipOutputFile.
Supports ZIP64 ext, Traditional PKWARE Encryption, WinZip AES Encryption.
This commit is contained in:
Ne-Lexa
2016-09-26 12:04:38 +03:00
parent 5c23e588ff
commit 560a94c910
48 changed files with 7785 additions and 2905 deletions

1049
tests/PhpZip/ZipTest.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,45 @@
<?php
namespace PhpZip;
/**
* PHPUnit test case and helper methods.
*/
class ZipTestCase extends \PHPUnit_Framework_TestCase
{
/**
* Assert correct zip archive.
*
* @param $filename
*/
public static function assertCorrectZipArchive($filename)
{
if (DIRECTORY_SEPARATOR !== '\\' && `which zip`) {
exec("zip -T " . escapeshellarg($filename), $output, $returnCode);
$output = implode(PHP_EOL, $output);
self::assertEquals($returnCode, 0);
self::assertNotContains('zip error', $output);
self::assertContains(' OK', $output);
}
}
/**
* Assert correct empty zip archive.
*
* @param $filename
*/
public static function assertCorrectEmptyZip($filename)
{
if (DIRECTORY_SEPARATOR !== '\\' && `which zipinfo`) {
exec("zipinfo " . escapeshellarg($filename), $output, $returnCode);
$output = implode(PHP_EOL, $output);
self::assertContains('Empty zipfile', $output);
}
$actualEmptyZipData = pack('VVVVVv', ZipConstants::END_OF_CENTRAL_DIRECTORY_RECORD_SIG, 0, 0, 0, 0, 0);
self::assertEquals(file_get_contents($filename), $actualEmptyZipData);
}
}