diff --git a/composer.json b/composer.json index 7a55c83..16b02fd 100644 --- a/composer.json +++ b/composer.json @@ -1,45 +1,47 @@ { - "name": "nelexa/zip", - "description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, ZipAlign tool, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.", - "type": "library", - "keywords": [ - "zip", - "unzip", - "archive", - "extract", - "winzip", - "zipalign", - "ziparchive" - ], - "require-dev": { - "phpunit/phpunit": "4.8" - }, - "license": "MIT", - "authors": [ - { - "name": "Ne-Lexa", - "email": "alexey@nelexa.ru", - "role": "Developer" - } - ], - "minimum-stability": "stable", - "require": { - "php": "^5.5 || ^7.0", - "psr/http-message": "^1.0" - }, - "autoload": { - "psr-4": { - "PhpZip\\": "src/PhpZip" - } - }, - "autoload-dev": { - "psr-4": { - "PhpZip\\": "tests/PhpZip" - } - }, - "suggest": { - "ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt", - "ext-mcrypt": "Needed to support encrypt zip entries or use ext-openssl", - "ext-bz2": "Needed to support BZIP2 compression" - } + "name": "nelexa/zip", + "type": "library", + "description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, ZipAlign tool, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.", + "keywords": [ + "zip", + "unzip", + "archive", + "extract", + "winzip", + "zipalign", + "ziparchive" + ], + "homepage": "https://github.com/Ne-Lexa/php-zip", + "license": "MIT", + "authors": [ + { + "name": "Ne-Lexa", + "email": "alexey@nelexa.ru", + "role": "Developer" + } + ], + "require": { + "php": "^5.5 || ^7.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.7", + "zendframework/zend-diactoros": "^1.4" + }, + "autoload": { + "psr-4": { + "PhpZip\\": "src/PhpZip" + } + }, + "autoload-dev": { + "psr-4": { + "PhpZip\\": "tests/PhpZip" + } + }, + "suggest": { + "ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt", + "ext-mcrypt": "Needed to support encrypt zip entries or use ext-openssl", + "ext-bz2": "Needed to support BZIP2 compression" + }, + "minimum-stability": "stable" } diff --git a/src/PhpZip/ZipFile.php b/src/PhpZip/ZipFile.php index 2d774f9..5806242 100644 --- a/src/PhpZip/ZipFile.php +++ b/src/PhpZip/ZipFile.php @@ -1302,11 +1302,11 @@ class ZipFile implements ZipFileInterface } $stream = new ResponseStream($handle); - $response->withHeader('Content-Type', $mimeType); - $response->withHeader('Content-Disposition', $contentDispositionValue); - $response->withHeader('Content-Length', $stream->getSize()); - $response->withBody($stream); - return $response; + return $response + ->withHeader('Content-Type', $mimeType) + ->withHeader('Content-Disposition', $contentDispositionValue) + ->withHeader('Content-Length', $stream->getSize()) + ->withBody($stream); } /** diff --git a/tests/PhpZip/ZipFileTest.php b/tests/PhpZip/ZipFileTest.php index 2adf1ee..4cbc75e 100644 --- a/tests/PhpZip/ZipFileTest.php +++ b/tests/PhpZip/ZipFileTest.php @@ -7,6 +7,7 @@ use PhpZip\Model\ZipInfo; use PhpZip\Util\CryptoUtil; use PhpZip\Util\FilesUtil; use Psr\Http\Message\ResponseInterface; +use Zend\Diactoros\Response; /** * ZipFile test @@ -1786,9 +1787,10 @@ class ZipFileTest extends ZipTestCase $zipFile[$i] = $i; } $filename = 'file.jar'; - $response = $this->getMock(ResponseInterface::class); - $response = $zipFile->outputAsResponse($response, $filename); + $response = $zipFile->outputAsResponse(new Response(), $filename); $this->assertInstanceOf(ResponseInterface::class, $response); + $this->assertEquals('application/java-archive', $response->getHeaderLine('content-type')); + $this->assertEquals('attachment; filename="file.jar"', $response->getHeaderLine('content-disposition')); } public function testCompressionLevel()