1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-07-30 20:20:11 +02:00

Merge tag '3.2.2' into develop

Tagging hotfix 3.2.2 3.2.2

# Conflicts:
#	.travis.yml
#	tests/ZipFileTest.php
This commit is contained in:
Ne-Lexa
2020-02-04 11:36:29 +03:00
4 changed files with 42 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ use PhpZip\Exception\InvalidArgumentException;
use PhpZip\Exception\ZipEntryNotFoundException;
use PhpZip\Exception\ZipException;
use PhpZip\Exception\ZipUnsupportMethodException;
use PhpZip\Model\Data\ZipFileData;
use PhpZip\Model\ZipEntry;
use PhpZip\Model\ZipInfo;
use PhpZip\Util\FilesUtil;
@@ -2459,6 +2460,10 @@ class ZipFileTest extends ZipTestCase
$zipFile->close();
}
/**
* @throws ZipEntryNotFoundException
* @throws ZipException
*/
public function testNoData()
{
$this->setExpectedException(ZipException::class, 'No data for zip entry file');
@@ -2476,4 +2481,34 @@ class ZipFileTest extends ZipTestCase
$zipFile->close();
}
}
/**
* @throws ZipEntryNotFoundException
* @throws ZipException
*/
public function testReplaceEntryContentsByFile()
{
$entryName = basename(__FILE__);
$zipFile = new ZipFile();
$zipFile[$entryName] = 'contents';
$zipFile->saveAsFile($this->outputFilename);
$zipFile->close();
$zipFile->openFile($this->outputFilename);
$entry = $zipFile->getEntry($entryName);
$data = new ZipFileData($entry, new \SplFileInfo(__FILE__));
$entry->setData($data);
$zipFile->saveAsFile($this->outputFilename);
$zipFile->close();
self::assertCorrectZipArchive($this->outputFilename);
$zipFile->openFile($this->outputFilename);
static::assertSame(
$zipFile->getEntryContents($entryName),
file_get_contents(__FILE__)
);
$zipFile->close();
}
}