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_slow.t | |
| parent | d2ef55e48f160f44a64188dddeade2d2b6d32ee3 (diff) | |
| download | itools-e1828e884f7c5475eea92ec13191ebd9c20ede92.tar.gz itools-e1828e884f7c5475eea92ec13191ebd9c20ede92.tar.bz2 itools-e1828e884f7c5475eea92ec13191ebd9c20ede92.zip | |
dry
Diffstat (limited to 'tests/it_url_slow.t')
| -rwxr-xr-x | tests/it_url_slow.t | 53 | 
1 files changed, 19 insertions, 34 deletions
| diff --git a/tests/it_url_slow.t b/tests/it_url_slow.t index 215528d..74440ce 100755 --- a/tests/it_url_slow.t +++ b/tests/it_url_slow.t @@ -5,27 +5,15 @@  # TESTFLAGS SLOW -$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 -); -usleep(100000); -stream_set_blocking($pipes[2], 0); -function server_output() { -	$result = array(); -	while (($result[] = trim(fgets($GLOBALS['pipes'][2])))) {}; -	return array_filter($result); -} +require 'it_url_server.php'; -$res = is( -	it_url::get('http://localhost:8000/short_sleep'), -	"Testserver output after short sleep", -	'it_url::get() waits for 4 seconds', +handle_server( +	is( +		it_url::get('http://localhost:8000/short_sleep'), +		"Testserver output after short sleep", +		'it_url::get() waits for 4 seconds', +	)  ); -$output = server_output(); -if (!$res) -	diag($output);  $start = microtime(true);  $res = ok( @@ -41,14 +29,13 @@ $output = server_output();  if (!$res || !$res2)  	diag($output); -$res = is( -	it_url::get('http://localhost:8000/slow_response'), -	join('', it::map('"Testserver slow output $v\n"', range(0, 5))), -	'it_url::get() waits for slow response with continuous output', +handle_server( +	is( +		it_url::get('http://localhost:8000/slow_response'), +		join('', it::map('"Testserver slow output $v\n"', range(0, 5))), +		'it_url::get() waits for slow response with continuous output', +	)  ); -$output = server_output(); -if (!$res) -	diag($output);  $start = microtime(true);  $res = ok( @@ -59,17 +46,15 @@ $res2 = is(  	floor(microtime(true) - $start), 5,  	'... and fails as soon as totaltimeout is surpassed'  ); +sleep(1); # wait for testserver  $output = server_output();  if (!$res || !$res2)  	diag($output); -$res = ok( -	it_url::get(U('http://localhost:8000/repeat', 'string' => "abc", 'num' => 1024 * 1024)) == str_repeat("abc", 1024 * 1024), -	'it_url::get() handles large response', +handle_server( +	ok( +		it_url::get(U('http://localhost:8000/repeat', 'string' => "abc", 'num' => 1024 * 1024)) == str_repeat("abc", 1024 * 1024), +		'it_url::get() handles large response', +	)  ); -$output = server_output(); -if (!$res) -	diag($output); - -proc_terminate($server); |