diff options
author | Nathan Gass | 2012-10-16 09:46:10 +0000 |
---|---|---|
committer | Nathan Gass | 2012-10-16 09:46:10 +0000 |
commit | e1828e884f7c5475eea92ec13191ebd9c20ede92 (patch) | |
tree | b3f4e3123bdd1fc24104528fe7453d2b113e982d /tests/it_url_server.php | |
parent | d2ef55e48f160f44a64188dddeade2d2b6d32ee3 (diff) | |
download | itools-e1828e884f7c5475eea92ec13191ebd9c20ede92.tar.gz itools-e1828e884f7c5475eea92ec13191ebd9c20ede92.tar.bz2 itools-e1828e884f7c5475eea92ec13191ebd9c20ede92.zip |
dry
Diffstat (limited to 'tests/it_url_server.php')
-rw-r--r-- | tests/it_url_server.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/it_url_server.php b/tests/it_url_server.php new file mode 100644 index 0000000..a407ab5 --- /dev/null +++ b/tests/it_url_server.php @@ -0,0 +1,33 @@ +<?php +$server = proc_open( + 'php -S localhost:8000 ' . dirname($_SERVER['PHP_SELF']) . '/it_url.testserver.php', + array(0 => fopen('/dev/null', 'r'), 1 => fopen('/dev/null', 'w'), 2 => array('pipe', 'w')), + $pipes +); +register_shutdown_function( + function ($server) { + proc_terminate($server); + }, + $server +); + +usleep(100000); +stream_set_blocking($pipes[2], 0); + +function server_output() { + $result = array(); + while (($result[] = trim(fgets($GLOBALS['pipes'][2])))) {}; + return array_filter($result); +} + +function handle_server($args) { + $res = true; + foreach ((array)$args as $arg) + $res = $res && $arg; + $output = server_output(); + if (!$res) + diag($output); + else + return $output; +} + |