⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
psa-pear
/
pear
/
php
/
test
/
horde
/
lz4
/
View File Name :
UnitTest.php
* @category Horde * @copyright 2013 Horde LLC * @ignore * @license http://www.php.net/license/3_01.txt PHP 3.01 * @package horde_lz4 * @subpackage UnitTests */ class horde_lz4_UnitTest extends PHPUnit_Framework_TestCase { private $data; public function setUp() { if (!extension_loaded('horde_lz4')) { $this->markTestSkipped('horde_lz4 extension not installed.'); } $this->data = file_get_contents(__DIR__ . '/fixtures/data.txt'); } // Test horde_lz4_compress() function : basic functionality public function testCompressBasic() { // Compressing a big string $output = horde_lz4_compress($this->data); $this->assertEquals( 0, strcmp(horde_lz4_uncompress($output), $this->data) ); // Compressing a smaller string $smallstring = "A small string to compress\n"; $output = horde_lz4_compress($smallstring); $this->assertEquals( 0, strcmp(horde_lz4_uncompress($output), $smallstring) ); } // Test horde_lz4_compress() function : error conditions public function testCompressErrorConditionOne() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); // Zero arguments horde_lz4_compress(); } // Test horde_lz4_compress() function : error conditions public function testCompressErrorConditionTwo() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); // Test horde_lz4_compress with one more than the expected number // of arguments $data = 'string_val'; $extra_arg = 10; horde_lz4_compress($data, false, $extra_arg); } // Test horde_lz4_compress() function : error conditions public function testCompressErrorConditionThree() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); horde_lz4_compress(new stdClass); } // Test horde_lz4_compress() function : variation public function testCompressVariation() { $output = horde_lz4_compress($this->data); $this->assertNotEquals( md5($output), md5(horde_lz4_compress($output)) ); } // Test horde_lz4_uncompress() function : basic functionality public function testUncompressBasic() { $compressed = horde_lz4_compress($this->data); $this->assertEquals( 0, strcmp($this->data, horde_lz4_uncompress($compressed)) ); } // Test horde_lz4_uncompress() function : error conditions public function testUncompressErrorConditionOne() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); // Zero arguments horde_lz4_uncompress(); } // Test horde_lz4_uncompress() function : error conditions public function testUncompressErrorConditionTwo() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); // Test horde_lz4_uncompress with one more than the expected number // of arguments $data = 'string_val'; $extra_arg = 10; horde_lz4_uncompress($data, $extra_arg); } // Test horde_lz4_uncompress() function : error conditions public function testUncompressErrorConditionThree() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); horde_lz4_uncompress(new stdClass); } // Test horde_lz4_uncompress() function : error conditions public function testUncompressErrorConditionFour() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); // Testing with incorrect arguments horde_lz4_uncompress(123); } // Test horde_lz4_compress() function : high compression public function testHighCompression() { // Compressing a big string $output = horde_lz4_compress($this->data, true); $this->assertEquals( 0, strcmp(horde_lz4_uncompress($output), $this->data) ); // Compressing a smaller string $smallstring = "A small string to compress\n"; $output = horde_lz4_compress($smallstring, true); $this->assertEquals( 0, strcmp(horde_lz4_uncompress($output), $smallstring) ); } // Test horde_lz4_uncompress() function : bad input (non-lz4 data) public function testUncompressBadInput() { // Bad data is missing the Horde-LZ4 header and is not LZ4 data. $bad_data = "12345678"; $this->assertFalse(horde_lz4_uncompress($bad_data)); } }