Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/zendframework/zendframework#6026-compress-filter…
Browse files Browse the repository at this point in the history
…-archive-path-fixes'

Close zendframework/zendframework#6026
  • Loading branch information
Ocramius committed Apr 2, 2014
3 parents 6b484d8 + fda1abb + 8ba3b2d commit 79a0d3d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Compress/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,12 @@ public function compress($content)
*/
public function decompress($content)
{
$archive = $this->getArchive();
$archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));

if (empty($archive) || !file_exists($archive)) {
throw new Exception\RuntimeException('ZIP Archive not found');
}

$archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
$zip = new ZipArchive();
$res = $zip->open($archive);

Expand Down
32 changes: 32 additions & 0 deletions test/Compress/ZipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,36 @@ public function testDecompressWillThrowExceptionWhenDecompressingWithNoTarget()
$content = file_get_contents($this->tmp . '/_compress');
$this->assertEquals('compress me', $content);
}

/**
* @group 6026
*
* @covers \Zend\Filter\Compress\Zip::decompress
*/
public function testDecompressWhenNoArchieveInClass()
{
if (!constant('TESTS_ZEND_FILTER_COMPRESS_ZIP_ENABLED')) {
$this->markTestSkipped('ZIP compression tests are currently disabled');
}

$filter = new ZipCompression(
array(
'archive' => $this->tmp . '/compressed.zip',
'target' => $this->tmp . '/_compress'
)
);

$content = $filter->compress('compress me');
$this->assertEquals($this->tmp . DIRECTORY_SEPARATOR . 'compressed.zip', $content);

$filter = new ZipCompression(
array(
'target' => $this->tmp . '/_compress'
)
);
$content = $filter->decompress($content);
$this->assertEquals($this->tmp . DIRECTORY_SEPARATOR, $content);
$content = file_get_contents($this->tmp . '/_compress');
$this->assertEquals('compress me', $content);
}
}

0 comments on commit 79a0d3d

Please sign in to comment.