- add gzip stream filter test
authorMichael Wallner <mike@php.net>
Sun, 18 Dec 2005 15:38:24 +0000 (15:38 +0000)
committerMichael Wallner <mike@php.net>
Sun, 18 Dec 2005 15:38:24 +0000 (15:38 +0000)
tests/stream_filters_002.phpt [new file with mode: 0644]

diff --git a/tests/stream_filters_002.phpt b/tests/stream_filters_002.phpt
new file mode 100644 (file)
index 0000000..3e12af6
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+gzip stream filters
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkver(5);
+skipif(!http_support(HTTP_SUPPORT_ENCODINGS), "need zlib support");
+?>
+--FILE--
+<?php
+
+echo "-TEST\n";
+
+$d = file_get_contents(__FILE__);
+$n = tempnam(dirname(__FILE__), 'hsf');
+
+$f = fopen($n, 'wb');
+stream_filter_append($f, 'http.gzencode', STREAM_FILTER_WRITE);
+fwrite($f, $d);
+fflush($f);
+fclose($f);
+$gzencoded = file_get_contents($n);
+
+$f = fopen($n, 'wb');
+stream_filter_append($f, 'http.deflate', STREAM_FILTER_WRITE);
+fwrite($f, $d);
+fflush($f);
+fclose($f);
+$deflated = file_get_contents($n);
+
+var_dump($d == http_gzdecode($gzencoded));
+var_dump($d == http_inflate($deflated));
+
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+bool(true)
+bool(true)
+Done