- Fixed build on php-trunk
[m6w6/ext-http] / tests / skip.inc
index 64dba3452f3e3ebf8ac0db9416690e07d36fed2e..d8770fb1fda6f405e690ddd3ab22f489a6352c06 100644 (file)
@@ -1,4 +1,15 @@
-<?php 
-extension_loaded('http') or die('skip ext/http not available');
-strncasecmp(PHP_SAPI, 'CLI', 3) or die('skip cannot run tests with CLI');
-?>
\ No newline at end of file
+<?php
+defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
+if (!function_exists('fprintf')) {
+       function fprintf(){ $a=func_get_args(); $s=array_shift($a); return fwrite($s, call_user_func_array('sprintf',$a)); }
+}
+function skipif($if, $skip) { if ($if) { fprintf(STDOUT, "skip $skip"); exit(); }}
+function checkcgi() { skipif(!strncasecmp('CLI', PHP_SAPI, 3), 'need CGI SAPI'); }
+function checkext($ext) { skipif(!extension_loaded($ext), "need ext/$ext"); }
+function checkmin($ver) { skipif(version_compare(PHP_VERSION, $ver) < 0, sprintf("need PHP >= v%s",$ver)); }
+function checkmax($ver) { skipif(version_compare(PHP_VERSION, $ver) > 0, sprintf("need PHP <= v%s",$ver)); }
+function checkurl($url) { skipif(!@fsockopen($url, 80), "$url not responsive"); }
+function checkcls($cls) { skipif(!class_exists($cls), "need class $cls"); }
+function checkver($ver) { checkmin($ver); }
+checkext('http');
+?>