add IO test
[m6w6/atick] / tests / lib / atick / IO / IOTest.php
1 <?php
2
3 namespace atick;
4
5 include __DIR__."/../../../setup.inc";
6
7 class IOTest extends \PHPUnit_Framework_TestCase {
8 protected $ticker;
9
10 function setUp() {
11 $this->ticker = new Ticker;
12 }
13
14 function testIO() {
15 $gzip = new IO\Process("gzip -1");
16 $base = new IO\Process("base64");
17 $func = new IO\Filter(function($f, $data, $eof) {
18 return strrev($data);
19 });
20
21 fwrite($gzip->getInput(), "Hello World!\n");
22 fclose($gzip->getInput());
23
24 $ticker = new Ticker;
25 $ticker->pipe($gzip, $base, $func, "fpassthru");
26
27 ob_start();
28 while($ticker(1));
29 $this->assertStringMatchesFormat("\nAAAAN0HFd3NACQeUJp8LPjwVJnczIN/AEI%sAIs4H", ob_get_contents());
30 }
31 }