dkelsey Wed Jan 21 15:24:11 2009 UTC Added files: /php-src/ext/zlib/tests zlib_scheme_file_get_contents_basic.phpt gzseek_variation6.phpt zlib_scheme_fopen_basic.phpt zlib_scheme_stat_basic.phpt zlib_scheme_file_read_file_basic.phpt zlib_scheme_copy_basic.phpt zlib_scheme_copy_variation1.phpt zlib_scheme_dir_basic.phpt zlib_scheme_copy_variation2.phpt zlib_scheme_file_basic.phpt zlib_scheme_stat_basic2.phpt gzseek_variation7.phpt zlib_scheme_unlink_basic.phpt zlib_scheme_rename_basic.phpt zlib_scheme_file_put_contents_basic.phpt gzopen_variation9.phpt gzopen_variation8.phpt Log: new tests for zlib extension, tested on windows, linux and linux64
http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt --TEST-- Test compress.zlib:// scheme with the file_get_contents --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; $contents = file_get_contents($srcFile); echo $contents; ?> ===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/gzseek_variation6.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/gzseek_variation6.phpt +++ php-src/ext/zlib/tests/gzseek_variation6.phpt --TEST-- Test function gzseek() by calling it with SEEK_END when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $f = dirname(__FILE__)."/004.txt.gz"; $h = gzopen($f, 'r'); // move 40 bytes echo "move 40 bytes\n"; gzread($h, 40); echo "tell="; var_dump(gztell($h)); echo "move to the end\n"; var_dump(gzseek( $h, 0, SEEK_END ) ); echo "tell="; var_dump(gztell($h)); echo "eof="; var_dump(gzeof($h)); //read the next 10 var_dump(gzread($h, 10)); gzclose($h); ?> ===DONE=== --EXPECTF-- move 40 bytes tell=int(40) move to the end
Warning: gzseek(): SEEK_END is not supported in %s on line %d int(-1) tell=int(40) eof=bool(false) string(10) "iny flying" ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_fopen_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_fopen_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_fopen_basic.phpt --TEST-- Test compress.zlib:// scheme with the fopen --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; $h = fopen($srcFile, 'r'); fpassthru($h); fclose($h); ?> ===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_stat_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_stat_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_stat_basic.phpt --TEST-- Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; stat($srcFile); lstat($srcFile); ?> ===DONE=== --EXPECTF-- Warning: stat(): stat failed for compress.zlib://%s/004.txt.gz in %s on line %d Warning: lstat(): Lstat failed for compress.zlib://%s/004.txt.gz in %s on line %d ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt --TEST-- Test compress.zlib:// scheme with the file_get_contents --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; readfile($srcFile); ?> ===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_copy_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_copy_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_copy_basic.phpt --TEST-- Test compress.zlib:// scheme with the copy function: compressed to compressed --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $outputFileName = __FILE__.'.tmp'; $srcFile = "compress.zlib://$inputFileName"; $destFile = "compress.zlib://$outputFileName"; copy($srcFile, $destFile); $h = gzopen($inputFileName, 'r'); $org_data = gzread($h, 4096); gzclose($h); $h = gzopen($outputFileName, 'r'); $copied_data = gzread($h, 4096); gzclose($h); if ($org_data == $copied_data) { echo "OK: Copy identical\n"; } else { echo "FAILED: Copy not identical"; } unlink($outputFileName); ?> ===DONE=== --EXPECT-- OK: Copy identical ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_copy_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_copy_variation1.phpt +++ php-src/ext/zlib/tests/zlib_scheme_copy_variation1.phpt --TEST-- Test compress.zlib:// scheme with the copy function: compressed to uncompressed --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $outputFileName = __FILE__.'.tmp'; $srcFile = "compress.zlib://$inputFileName"; $destFile = $outputFileName; copy($srcFile, $destFile); $h = gzopen($inputFileName, 'r'); $org_data = gzread($h, 4096); gzclose($h); // can only read uncompressed data $h = fopen($outputFileName, 'r'); $copied_data = fread($h, 4096); gzclose($h); if ($org_data == $copied_data) { echo "OK: Copy identical\n"; } else { echo "FAILED: Copy not identical"; } unlink($outputFileName); ?> ===DONE=== --EXPECT-- OK: Copy identical ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_dir_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_dir_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_dir_basic.phpt --TEST-- Test compress.zlib:// scheme with the directory functions --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/dir.gz"; $srcFile = "compress.zlib://$inputFileName"; var_dump(mkdir($srcFile)); var_dump(is_dir($srcFile)); var_dump(opendir($srcFile)); var_dump(rmdir($srcFile)); ?> ===DONE=== --EXPECTF-- bool(false) bool(false) Warning: opendir(compress.zlib://%s/dir.gz): failed to open dir: not implemented in %s on line %d bool(false) bool(false) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_copy_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_copy_variation2.phpt +++ php-src/ext/zlib/tests/zlib_scheme_copy_variation2.phpt --TEST-- Test compress.zlib:// scheme with the copy function: uncompressed to compressed --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $org_data = <<<EOT uncompressed contents of 004.txt.gz is: When you're taught through feelings Destiny flying high above all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me EOT; $inputFileName = __FILE__.'.org'; $outputFileName = __FILE__.'.tmp'; file_put_contents($inputFileName, $org_data); $srcFile = $inputFileName; $destFile = "compress.zlib://$outputFileName"; copy($srcFile, $destFile); $h = gzopen($outputFileName, 'r'); $copied_data = gzread($h, 4096); gzclose($h); //gzopen can read compressed and uncompressed so we //also need to look for the magic number (x1f x8b) to prove it //was compressed. $h = fopen($outputFileName, 'r'); $magic = fread($h, 2); fclose($h); if ($org_data == $copied_data && bin2hex($magic) === '1f8b') { echo "OK: Copy identical\n"; } else { echo "FAILED: Copy not identical\n"; } unlink($inputFileName); unlink($outputFileName); ?> ===DONE=== --EXPECT-- OK: Copy identical ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_file_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_file_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_file_basic.phpt --TEST-- Test compress.zlib:// scheme with the file --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; $contents = file($srcFile); var_dump($contents); ?> ===DONE=== --EXPECT-- array(6) { [0]=> string(36) "When you're taught through feelings " [1]=> string(26) "Destiny flying high above " [2]=> string(38) "all I know is that you can realize it " [3]=> string(18) "Destiny who cares " [4]=> string(19) "as it turns around " [5]=> string(39) "and I know that it descends down on me " } ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_stat_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_stat_basic2.phpt +++ php-src/ext/zlib/tests/zlib_scheme_stat_basic2.phpt --TEST-- Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; echo "file_exists="; var_dump(file_exists($srcFile)); echo "is_file="; var_dump(is_file($srcFile)); echo "is_dir="; var_dump(is_dir($srcFile)); echo "is_readable="; var_dump(is_readable($srcFile)); echo "\n"; echo "filesize="; var_dump(filesize($srcFile)); echo "filetype="; var_dump(filetype($srcFile)); echo "fileatime="; var_dump(fileatime($srcFile)); ?> ===DONE=== --EXPECTF-- file_exists=bool(false) is_file=bool(false) is_dir=bool(false) is_readable=bool(false) filesize= Warning: filesize(): stat failed for compress.zlib://%s004.txt.gz in %s on line %d bool(false) filetype= Warning: filetype(): Lstat failed for compress.zlib://%s004.txt.gz in %s on line %d bool(false) fileatime= Warning: fileatime(): stat failed for compress.zlib://%s004.txt.gz in %s on line %d bool(false) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/gzseek_variation7.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/gzseek_variation7.phpt +++ php-src/ext/zlib/tests/gzseek_variation7.phpt --TEST-- Test function gzseek() by calling it with SEEK_END when writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $f = "temp3.txt.gz"; $h = gzopen($f, 'w'); $str1 = "This is the first line."; $str2 = "This is the second line."; gzwrite($h, $str1); echo "tell="; var_dump(gztell($h)); //seek to the end which is not sensible of course. echo "move to the end of the file\n"; var_dump(gzseek($h, 0, SEEK_END)); echo "tell="; var_dump(gztell($h)); gzwrite($h, $str2); echo "tell="; var_dump(gztell($h)); gzclose($h); echo "\nreading the output file\n"; $h = gzopen($f, 'r'); gzpassthru($h); gzclose($h); echo "\n"; unlink($f); ?> ===DONE=== --EXPECTF-- tell=int(23) move to the end of the file Warning: gzseek(): SEEK_END is not supported in %s on line %d int(-1) tell=int(23) tell=int(47) reading the output file This is the first line.This is the second line. ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_unlink_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_unlink_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_unlink_basic.phpt --TEST-- Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; unlink($srcFile); var_dump(file_exists($inputFileName)); ?> ===DONE=== --EXPECTF-- Warning: unlink(): ZLIB does not allow unlinking in %s on line %d bool(true) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_rename_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_rename_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_rename_basic.phpt --TEST-- Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $inputFileName = dirname(__FILE__)."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; rename($srcFile, 'something.tmp'); var_dump(file_exists($inputFileName)); ?> ===DONE=== --EXPECTF-- Warning: rename(): ZLIB wrapper does not support renaming in %s on line %d bool(true) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt +++ php-src/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt --TEST-- Test compress.zlib:// scheme with the file_get_contents --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php $outputFileName = __FILE__.'tmp'; $outFile = "compress.zlib://$outputFileName"; $data = <<<EOT Here is some plain text to be read and displayed. EOT; file_put_contents($outFile, $data); $h = gzopen($outputFileName, 'r'); gzpassthru($h); gzclose($h); echo "\n"; unlink($outputFileName); ?> ===DONE=== --EXPECT-- Here is some plain text to be read and displayed. ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/gzopen_variation9.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/gzopen_variation9.phpt +++ php-src/ext/zlib/tests/gzopen_variation9.phpt --TEST-- Test gzopen() function : variation: try opening with possibly invalid modes --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php /* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) * Description: Open a .gz-file and return a .gz-file pointer * Source code: ext/zlib/zlib.c * Alias to functions: */ echo "*** Testing gzopen() : variation ***\n"; $modes = array('r+', 'rf', 'w+' , 'e'); $file = dirname(__FILE__)."/004.txt.gz"; foreach ($modes as $mode) { echo "mode=$mode\n"; $h = gzopen($file, $mode); echo "gzopen="; var_dump($h); if ($h !== false) { gzclose($h); } echo "\n"; } ?> ===DONE=== --EXPECTF-- *** Testing gzopen() : variation *** mode=r+ Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d gzopen=bool(false) mode=rf gzopen=resource(%d) of type (stream) mode=w+ Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d gzopen=bool(false) mode=e Warning: gzopen(%s/004.txt.gz): failed to open stream: %s in %s on line %d gzopen=bool(false) ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/gzopen_variation8.phpt?view=markup&rev=1.1 Index: php-src/ext/zlib/tests/gzopen_variation8.phpt +++ php-src/ext/zlib/tests/gzopen_variation8.phpt --TEST-- Test gzopen() function : variation: opening a plain file --SKIPIF-- <?php if (!extension_loaded("zlib")) { print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php /* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) * Description: Open a .gz-file and return a .gz-file pointer * Source code: ext/zlib/zlib.c * Alias to functions: */ echo "*** Testing gzopen() : variation ***\n"; $data = <<<EOT Here is some plain text to be read and displayed. EOT; $file = "gzopen_variation8.tmp"; $h = fopen($file, 'w'); fwrite($h, $data); fclose($h); $h = gzopen($file, 'r'); gzpassthru($h); gzclose($h); echo "\n"; unlink($file); ?> ===DONE=== --EXPECT-- *** Testing gzopen() : variation *** Here is some plain text to be read and displayed. ===DONE===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php