Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

115 lines (96 sloc) 3.13 kB
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/
namespace ZendTest\Filter;
use Zend\Filter\Decompress as DecompressFilter;
/**
* @category Zend
* @package Zend_Filter
* @subpackage UnitTests
* @group Zend_Filter
*/
class DecompressTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!extension_loaded('bz2')) {
$this->markTestSkipped('This filter is tested with the bz2 extension');
}
}
public function tearDown()
{
if (file_exists(__DIR__ . '/../_files/compressed.bz2')) {
unlink(__DIR__ . '/../_files/compressed.bz2');
}
}
/**
* Basic usage
*
* @return void
*/
public function testBasicUsage()
{
if (version_compare(phpversion(), '5.4', '>=')) {
$this->markTestIncomplete('Code to test is not compatible with PHP 5.4 ');
}
$filter = new DecompressFilter('bz2');
$text = 'compress me';
$compressed = $filter->compress($text);
$this->assertNotEquals($text, $compressed);
$decompressed = $filter($compressed);
$this->assertEquals($text, $decompressed);
}
/**
* Setting Archive
*
* @return void
*/
public function testCompressToFile()
{
$filter = new DecompressFilter('bz2');
$archive = __DIR__ . '/../_files/compressed.bz2';
$filter->setArchive($archive);
$content = $filter->compress('compress me');
$this->assertTrue($content);
$filter2 = new DecompressFilter('bz2');
$content2 = $filter2($archive);
$this->assertEquals('compress me', $content2);
$filter3 = new DecompressFilter('bz2');
$filter3->setArchive($archive);
$content3 = $filter3(null);
$this->assertEquals('compress me', $content3);
}
/**
* Basic usage
*
* @return void
*/
public function testDecompressArchive()
{
$filter = new DecompressFilter('bz2');
$archive = __DIR__ . '/../_files/compressed.bz2';
$filter->setArchive($archive);
$content = $filter->compress('compress me');
$this->assertTrue($content);
$filter2 = new DecompressFilter('bz2');
$content2 = $filter2($archive);
$this->assertEquals('compress me', $content2);
}
public function testFilterMethodProxiesToDecompress()
{
$filter = new DecompressFilter('bz2');
$archive = __DIR__ . '/../_files/compressed.bz2';
$filter->setArchive($archive);
$content = $filter->compress('compress me');
$this->assertTrue($content);
$filter2 = new DecompressFilter('bz2');
$content2 = $filter2->filter($archive);
$this->assertEquals('compress me', $content2);
}
}
Jump to Line
Something went wrong with that request. Please try again.