mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-03-21 06:59:40 +01:00
added an additional test of the encrypted archive
This commit is contained in:
parent
c34f90ac18
commit
aa09b24d02
@ -224,7 +224,7 @@ class ZipModel implements \Countable
|
||||
if (isset($this->outEntries[$entryName])) {
|
||||
return $this->outEntries[$entryName];
|
||||
}
|
||||
throw new ZipNotFoundEntry('Zip entry ' . $entryName . ' not found');
|
||||
throw new ZipNotFoundEntry('Zip entry "' . $entryName . '" not found');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,7 +239,6 @@ class ZipOutputStream implements ZipOutputStreamInterface
|
||||
$field = $extraFieldsCollection->get(WinZipAesEntryExtraField::getHeaderId());
|
||||
if (null !== $field) {
|
||||
$method = $field->getMethod();
|
||||
$entry->setMethod($method);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
Loading…
x
Reference in New Issue
Block a user