add brotli filter and tests
[m6w6/ext-http] / tests / encstream016.phpt
diff --git a/tests/encstream016.phpt b/tests/encstream016.phpt
new file mode 100644 (file)
index 0000000..2ecf9b6
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+encoding stream brotli auto flush
+--SKIPIF--
+<?php
+include "skipif.inc";
+class_exists("http\\Encoding\\Stream\\Enbrotli") or die("SKIP need brotli support");
+
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$defl = new http\Encoding\Stream\Enbrotli(http\Encoding\Stream::FLUSH_FULL);
+$infl = new http\Encoding\Stream\Debrotli;
+
+for ($f = fopen(__FILE__, "rb"); !feof($f); $data = fread($f, 0x100)) {
+       if (isset($data)) {
+               if ($data !== $d=$infl->update($defl->update($data))) {
+                       printf("uh-oh »%s« != »%s«\n", $data, $d);
+               }
+       }
+}
+
+echo $infl->update($defl->finish());
+echo $infl->finish();
+
+var_dump($infl->done(), $defl->done());
+?>
+DONE
+--EXPECT--
+Test
+bool(true)
+bool(true)
+DONE