1--TEST--
2Test gzcompress() function : basic functionality
3--EXTENSIONS--
4zlib
5--SKIPIF--
6<?php if (getenv('TRAVIS')) die('skip Currently fails on Travis'); ?>
7--FILE--
8<?php
9/*
10 * add a comment here to say what the test is supposed to do
11 */
12
13include(__DIR__ . '/data.inc');
14
15echo "*** Testing gzcompress() : basic functionality ***\n";
16
17// Initialise all required variables
18
19$smallstring = "A small string to compress\n";
20
21
22// Calling gzcompress() with all possible arguments
23
24// Compressing a big string
25for($i = -1; $i < 10; $i++) {
26    echo "-- Compression level $i --\n";
27    $output = gzcompress($data, $i);
28    var_dump(md5($output));
29    var_dump(strcmp(gzuncompress($output), $data));
30}
31
32// Compressing a smaller string
33for($i = -1; $i < 10; $i++) {
34    echo "-- Compression level $i --\n";
35    $output = gzcompress($smallstring, $i);
36    var_dump(bin2hex($output));
37    var_dump(strcmp(gzuncompress($output), $smallstring));
38}
39
40// Calling gzcompress() with mandatory arguments
41echo "\n-- Testing with no specified compression level --\n";
42var_dump( bin2hex(gzcompress($smallstring) ));
43
44?>
45--EXPECT--
46*** Testing gzcompress() : basic functionality ***
47-- Compression level -1 --
48string(32) "764809aef15bb34cb73ad49ecb600d99"
49int(0)
50-- Compression level 0 --
51string(32) "d0136b3fb5424142c0eb26dfec8f56fe"
52int(0)
53-- Compression level 1 --
54string(32) "c2e070f4320d1f674965eaab95b53d9c"
55int(0)
56-- Compression level 2 --
57string(32) "36922f486410d08209d0d0d21b26030e"
58int(0)
59-- Compression level 3 --
60string(32) "a441a2f5169bb303cd45b860a5a9dbf9"
61int(0)
62-- Compression level 4 --
63string(32) "d5b7451e9de2864beccc9de1fc55eb87"
64int(0)
65-- Compression level 5 --
66string(32) "32ba4a01120449ec25508cabfad41f56"
67int(0)
68-- Compression level 6 --
69string(32) "764809aef15bb34cb73ad49ecb600d99"
70int(0)
71-- Compression level 7 --
72string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
73int(0)
74-- Compression level 8 --
75string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
76int(0)
77-- Compression level 9 --
78string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
79int(0)
80-- Compression level -1 --
81string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
82int(0)
83-- Compression level 0 --
84string(76) "7801011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a87a509cb"
85int(0)
86-- Compression level 1 --
87string(70) "7801735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
88int(0)
89-- Compression level 2 --
90string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
91int(0)
92-- Compression level 3 --
93string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
94int(0)
95-- Compression level 4 --
96string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
97int(0)
98-- Compression level 5 --
99string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
100int(0)
101-- Compression level 6 --
102string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
103int(0)
104-- Compression level 7 --
105string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
106int(0)
107-- Compression level 8 --
108string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
109int(0)
110-- Compression level 9 --
111string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
112int(0)
113
114-- Testing with no specified compression level --
115string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
116