Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ZipStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,11 @@ protected function addCdrFile($args) {
), // central file header signature
array(
'v',
(6 << 8) + 3
0x003F // Ver 6.3, OS_FAT
), // version made by
array(
'v',
(6 << 8) + 3
0x0014 // Ver 2.0, OS_FAT
), // version needed to extract
array(
'v',
Expand Down
29 changes: 29 additions & 0 deletions test/ZipStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* @copyright Copyright (c) 2014, Jonatan Männchen
*/
class ZipStreamTest extends PHPUnit_Framework_TestCase {
const OSX_ARCHIVE_UTILITY = '/System/Library/CoreServices/Applications/Archive Utility.app/Contents/MacOS/Archive Utility';

/**
* @expectedException \ZipStream\Exception\InvalidOptionException
*/
Expand Down Expand Up @@ -109,6 +111,33 @@ public function testAddFileWithStorageMethod()
$zipArch->close();
}

public function testDecompressFileWithMacUnarchiver()
{
if(!file_exists(self::OSX_ARCHIVE_UTILITY)) {
$this->markTestSkipped('The Mac OSX Archive Utility is not available.');
}

list($tmp, $stream) = $this->getTmpFileStream();

$zip = new ZipStream(null, array(
ZipStream::OPTION_OUTPUT_STREAM => $stream
));

$folder = uniqid();

$zip->addFile($folder . '/sample.txt', 'Sample Data');
$zip->finish();
fclose($stream);

exec(escapeshellarg(self::OSX_ARCHIVE_UTILITY) . ' ' . escapeshellarg($tmp), $output, $returnStatus);

$this->assertEquals(0, $returnStatus);
$this->assertCount(0, $output);

$this->assertFileExists(dirname($tmp) . '/' . $folder . '/sample.txt');
$this->assertEquals('Sample Data', file_get_contents(dirname($tmp) . '/' . $folder . '/sample.txt'));
}

public function testAddFileFromPath() {
list($tmp, $stream) = $this->getTmpFileStream();

Expand Down