Annotation of embedaddon/php/ext/zlib/tests/zlib_scheme_copy_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test compress.zlib:// scheme with the copy function: uncompressed to compressed
3: --SKIPIF--
4: <?php
5: if (!extension_loaded("zlib")) {
6: print "skip - ZLIB extension not loaded";
7: }
8: ?>
9: --FILE--
10: <?php
11: $org_data = <<<EOT
12: uncompressed contents of 004.txt.gz is:
13: When you're taught through feelings
14: Destiny flying high above
15: all I know is that you can realize it
16: Destiny who cares
17: as it turns around
18: and I know that it descends down on me
19: EOT;
20:
21: $inputFileName = __FILE__.'.org';
22: $outputFileName = __FILE__.'.tmp';
23:
24: file_put_contents($inputFileName, $org_data);
25:
26: $srcFile = $inputFileName;
27: $destFile = "compress.zlib://$outputFileName";
28: copy($srcFile, $destFile);
29:
30: $h = gzopen($outputFileName, 'r');
31: $copied_data = gzread($h, 4096);
32: gzclose($h);
33:
34: //gzopen can read compressed and uncompressed so we
35: //also need to look for the magic number (x1f x8b) to prove it
36: //was compressed.
37: $h = fopen($outputFileName, 'r');
38: $magic = fread($h, 2);
39: fclose($h);
40:
41: if ($org_data == $copied_data && bin2hex($magic) === '1f8b') {
42: echo "OK: Copy identical\n";
43: }
44: else {
45: echo "FAILED: Copy not identical\n";
46: }
47: unlink($inputFileName);
48: unlink($outputFileName);
49: ?>
50: ===DONE===
51: --EXPECT--
52: OK: Copy identical
53: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>