ZF-8222: format class name for class checks
[zend.git] / tests / Zend / Filter / DecompressTest.php
blobe40af548c55d0cc8e54ddab9092ccb1d3b63e9e8
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Filter
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: $
23 if (!defined('PHPUnit_MAIN_METHOD')) {
24 define('PHPUnit_MAIN_METHOD', 'Zend_Filter_DecompressTest::main');
27 /**
28 * Test helper
30 require_once dirname(__FILE__) . '/../../TestHelper.php';
32 /**
33 * @see Zend_Filter_Decompress
35 require_once 'Zend/Filter/Decompress.php';
37 /**
38 * @category Zend
39 * @package Zend_Filter
40 * @subpackage UnitTests
41 * @group Zend_Filter
42 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
43 * @license http://framework.zend.com/license/new-bsd New BSD License
45 class Zend_Filter_DecompressTest extends PHPUnit_Framework_TestCase
47 /**
48 * Runs this test suite
50 * @return void
52 public static function main()
54 $suite = new PHPUnit_Framework_TestSuite('Zend_Filter_DecompressTest');
55 $result = PHPUnit_TextUI_TestRunner::run($suite);
58 public function setUp()
60 if (!extension_loaded('bz2')) {
61 $this->markTestSkipped('This filter is tested with the bz2 extension');
65 public function tearDown()
67 if (file_exists(dirname(__FILE__) . '/../_files/compressed.bz2')) {
68 unlink(dirname(__FILE__) . '/../_files/compressed.bz2');
72 /**
73 * Basic usage
75 * @return void
77 public function testBasicUsage()
79 $filter = new Zend_Filter_Decompress('bz2');
81 $text = 'compress me';
82 $compressed = $filter->compress($text);
83 $this->assertNotEquals($text, $compressed);
85 $decompressed = $filter->filter($compressed);
86 $this->assertEquals($text, $decompressed);
89 /**
90 * Setting Archive
92 * @return void
94 public function testCompressToFile()
96 $filter = new Zend_Filter_Decompress('bz2');
97 $archive = dirname(__FILE__) . '/../_files/compressed.bz2';
98 $filter->setArchive($archive);
100 $content = $filter->compress('compress me');
101 $this->assertTrue($content);
103 $filter2 = new Zend_Filter_Decompress('bz2');
104 $content2 = $filter2->filter($archive);
105 $this->assertEquals('compress me', $content2);
107 $filter3 = new Zend_Filter_Decompress('bz2');
108 $filter3->setArchive($archive);
109 $content3 = $filter3->filter(null);
110 $this->assertEquals('compress me', $content3);
114 * Basic usage
116 * @return void
118 public function testDecompressArchive()
120 $filter = new Zend_Filter_Decompress('bz2');
121 $archive = dirname(__FILE__) . '/../_files/compressed.bz2';
122 $filter->setArchive($archive);
124 $content = $filter->compress('compress me');
125 $this->assertTrue($content);
127 $filter2 = new Zend_Filter_Decompress('bz2');
128 $content2 = $filter2->filter($archive);
129 $this->assertEquals('compress me', $content2);
133 if (PHPUnit_MAIN_METHOD == 'Zend_Filter_DecompressTest::main') {
134 Zend_Filter_DecompressTest::main();