mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-08-10 01:16:29 +02:00
solving problems with lack of memory, the new ZipReader and ZipWriter class, adds .phpstorm.meta.php
#13 #16 #27 #31 #41
This commit is contained in:
56
tests/Issue24Test.php
Normal file
56
tests/Issue24Test.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace PhpZip\Tests;
|
||||
|
||||
use PhpZip\Exception\ZipException;
|
||||
use PhpZip\Tests\Internal\DummyFileSystemStream;
|
||||
use PhpZip\ZipFile;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @small
|
||||
*/
|
||||
class Issue24Test extends ZipTestCase
|
||||
{
|
||||
const PROTO_DUMMYFS = 'dummyfs';
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
stream_wrapper_register(self::PROTO_DUMMYFS, DummyFileSystemStream::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ZipException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testDummyFS()
|
||||
{
|
||||
$fileContents = str_repeat(base64_encode(random_bytes(12000)), 100);
|
||||
|
||||
// create zip file
|
||||
$zip = new ZipFile();
|
||||
$zip->addFromString(
|
||||
'file.txt',
|
||||
$fileContents,
|
||||
ZipFile::METHOD_DEFLATED
|
||||
);
|
||||
$zip->saveAsFile($this->outputFilename);
|
||||
$zip->close();
|
||||
|
||||
static::assertCorrectZipArchive($this->outputFilename);
|
||||
|
||||
$uri = self::PROTO_DUMMYFS . '://localhost/' . $this->outputFilename;
|
||||
$stream = fopen($uri, 'rb');
|
||||
static::assertNotFalse($stream);
|
||||
$zip->openFromStream($stream);
|
||||
static::assertSame($zip->getListFiles(), ['file.txt']);
|
||||
static::assertSame($zip['file.txt'], $fileContents);
|
||||
$zip->close();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user