add IO test master
authorMichael Wallner <mike@php.net>
Mon, 25 Nov 2013 10:51:21 +0000 (11:51 +0100)
committerMichael Wallner <mike@php.net>
Mon, 25 Nov 2013 10:51:21 +0000 (11:51 +0100)
tests/lib/atick/IO/IOTest.php [new file with mode: 0644]

diff --git a/tests/lib/atick/IO/IOTest.php b/tests/lib/atick/IO/IOTest.php
new file mode 100644 (file)
index 0000000..f95f2ea
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace atick;
+
+include __DIR__."/../../../setup.inc";
+
+class IOTest extends \PHPUnit_Framework_TestCase {
+       protected $ticker;
+       
+       function setUp() {
+               $this->ticker = new Ticker;
+       }
+       
+       function testIO() {
+               $gzip = new IO\Process("gzip -1");
+               $base = new IO\Process("base64");
+               $func = new IO\Filter(function($f, $data, $eof) {
+                       return strrev($data);
+               });
+               
+               fwrite($gzip->getInput(), "Hello World!\n");
+               fclose($gzip->getInput());
+               
+               $ticker = new Ticker;
+               $ticker->pipe($gzip, $base, $func, "fpassthru");
+
+               ob_start();
+               while($ticker(1));
+               $this->assertStringMatchesFormat("\nAAAAN0HFd3NACQeUJp8LPjwVJnczIN/AEI%sAIs4H", ob_get_contents());
+       }
+}