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