mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-07-30 20:20:11 +02:00
added an additional test of the encrypted archive
This commit is contained in:
@@ -1672,7 +1672,7 @@ class ZipFileTest extends ZipTestCase
|
||||
|
||||
/**
|
||||
* @expectedException \PhpZip\Exception\ZipNotFoundEntry
|
||||
* @expectedExceptionMessage Zip entry bad entry name not found
|
||||
* @expectedExceptionMessage Zip entry "bad entry name" not found
|
||||
*/
|
||||
public function testNotFoundEntry()
|
||||
{
|
||||
|
@@ -370,4 +370,30 @@ class ZipPasswordTest extends ZipFileAddDirTest
|
||||
$this->assertEquals($zipFile['codes.csv'], $contents);
|
||||
$zipFile->close();
|
||||
}
|
||||
|
||||
public function testReadAesEncryptedAndRewriteArchive()
|
||||
{
|
||||
$file = __DIR__ . '/resources/aes_password_archive.zip';
|
||||
$password = '1234567890';
|
||||
|
||||
$zipFile = new ZipFile();
|
||||
$zipFile->openFile($file);
|
||||
$zipFile->setReadPassword($password);
|
||||
$zipFile->setEntryComment('contents.txt', 'comment'); // change entry, but not changed contents
|
||||
$zipFile->saveAsFile($this->outputFilename);
|
||||
|
||||
$zipFile2 = new ZipFile();
|
||||
$zipFile2->openFile($this->outputFilename);
|
||||
$zipFile2->setReadPassword($password);
|
||||
$this->assertEquals($zipFile2->getListFiles(), $zipFile->getListFiles());
|
||||
foreach ($zipFile as $name => $contents) {
|
||||
$this->assertNotEmpty($name);
|
||||
$this->assertNotEmpty($contents);
|
||||
$this->assertContains('test contents', $contents);
|
||||
$this->assertEquals($zipFile2[$name], $contents);
|
||||
}
|
||||
$zipFile2->close();
|
||||
|
||||
$zipFile->close();
|
||||
}
|
||||
}
|
||||
|
BIN
tests/PhpZip/resources/aes_password_archive.zip
Normal file
BIN
tests/PhpZip/resources/aes_password_archive.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user