diff --git a/library/Zend/Filter/Compress/Tar.php b/library/Zend/Filter/Compress/Tar.php index 16ca08e2e65..f8a3d3129c2 100644 --- a/library/Zend/Filter/Compress/Tar.php +++ b/library/Zend/Filter/Compress/Tar.php @@ -126,16 +126,16 @@ public function getMode() */ public function setMode($mode) { - $mode = ucfirst(strtolower($mode)); - if (($mode != 'Bz2') && ($mode != 'Gz')) { + $mode = strtolower($mode); + if (($mode != 'bz2') && ($mode != 'gz')) { throw new Exception\InvalidArgumentException("The mode '$mode' is unknown"); } - if (($mode == 'Bz2') && (!extension_loaded('bz2'))) { + if (($mode == 'bz2') && (!extension_loaded('bz2'))) { throw new Exception\ExtensionNotLoadedException('This mode needs the bz2 extension'); } - if (($mode == 'Gz') && (!extension_loaded('zlib'))) { + if (($mode == 'gz') && (!extension_loaded('zlib'))) { throw new Exception\ExtensionNotLoadedException('This mode needs the zlib extension'); } diff --git a/tests/ZendTest/Filter/Compress/TarTest.php b/tests/ZendTest/Filter/Compress/TarTest.php index f14b76b9427..c9f0b373531 100644 --- a/tests/ZendTest/Filter/Compress/TarTest.php +++ b/tests/ZendTest/Filter/Compress/TarTest.php @@ -70,7 +70,9 @@ public function tearDown() dirname(__DIR__) . '/_files/_compress/Compress', dirname(__DIR__) . '/_files/_compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress', - dirname(__DIR__) . '/_files/compressed.tar' + dirname(__DIR__) . '/_files/compressed.tar', + dirname(__DIR__) . '/_files/compressed.tar.gz', + dirname(__DIR__) . '/_files/compressed.tar.bz2' ); foreach ($files as $file) { @@ -215,6 +217,20 @@ public function testTarCompressDirectory() . DIRECTORY_SEPARATOR . 'compressed.tar', $content); } + public function testSetModeShouldWorkWithCaseInsensitive() + { + $filter = new TarCompression; + $filter->setTarget(dirname(__DIR__).'/_files/zipextracted.txt'); + + foreach(array('GZ', 'Bz2') as $mode) { + $archive = dirname(__DIR__).'/_files/compressed.tar.'.strtolower($mode); + $filter->setArchive($archive); + $filter->setMode($mode); + $content = $filter->compress('compress me'); + $this->assertEquals($archive, $content); + } + } + /** * testing toString *