1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-07-25 09:41:14 +02:00

added method outputAsSymfonyResponse, rename method outputAsResponse to outputAsPsr7Response

This commit is contained in:
Ne-Lexa
2021-02-24 15:37:11 +03:00
parent e8418d57b1
commit a11c6367b4
6 changed files with 273 additions and 78 deletions

View File

@@ -1856,7 +1856,7 @@ class ZipFileTest extends ZipTestCase
public function testFilename0(): void
{
$zipFile = new ZipFile();
$zipFile[0] = 0;
$zipFile[0] = '0';
static::assertTrue(isset($zipFile['0']));
static::assertCount(1, $zipFile);
$zipFile
@@ -1891,18 +1891,33 @@ class ZipFileTest extends ZipTestCase
/**
* @throws ZipException
*/
public function testPsrResponse(): void
public function testOutputAsPsr7Response(): void
{
$zipFile = new ZipFile();
for ($i = 0; $i < 10; $i++) {
$zipFile[$i] = $i;
$zipFile[$i] = (string) $i;
}
$filename = 'file.jar';
$response = $zipFile->outputAsResponse(new Response(), $filename);
$response = $zipFile->outputAsPsr7Response(new Response(), $filename);
static::assertSame('application/java-archive', $response->getHeaderLine('content-type'));
static::assertSame('attachment; filename="file.jar"', $response->getHeaderLine('content-disposition'));
}
/**
* @throws ZipException
*/
public function testOutputAsSymfonyResponse(): void
{
$zipFile = new ZipFile();
for ($i = 0; $i < 10; $i++) {
$zipFile[$i] = (string) $i;
}
$filename = 'file.jar';
$response = $zipFile->outputAsSymfonyResponse($filename);
static::assertSame('application/java-archive', $response->headers->get('content-type'));
static::assertSame('attachment; filename="file.jar"', $response->headers->get('content-disposition'));
}
/**
* @dataProvider provideCompressionLevels
*