add pecl/http-v2 tests; release 1.0.3
[m6w6/ext-raphf] / tests / http002.phpt
diff --git a/tests/http002.phpt b/tests/http002.phpt
new file mode 100644 (file)
index 0000000..99d7260
--- /dev/null
@@ -0,0 +1,71 @@
+--TEST--
+pecl/http-v2 - clean with name and id
+--SKIPIF--
+<?php
+if (!extension_loaded("http")) {
+       die("skip pecl/http needed");
+}
+if (!class_exists("http\\Client", false)) {
+       die("skip pecl/http-v2 with curl support needed");
+}
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$c = new http\Client("curl", "php.net:80");
+do {
+       $c->enqueue(new http\Client\Request("GET", "http://php.net"));
+} while (count($c) < 3);
+
+unset($c);
+
+var_dump(raphf\stat_persistent_handles());
+
+raphf\clean_persistent_handles("http\\Client\\Curl");
+raphf\clean_persistent_handles("http\\Client\\Curl\\Request", "php.net:80");
+
+var_dump(raphf\stat_persistent_handles());
+
+?>
+Done
+--EXPECTF--
+Test
+object(stdClass)#%d (2) {
+  ["http\Client\Curl"]=>
+  array(1) {
+    ["php.net:80"]=>
+    array(2) {
+      ["used"]=>
+      int(0)
+      ["free"]=>
+      int(1)
+    }
+  }
+  ["http\Client\Curl\Request"]=>
+  array(1) {
+    ["php.net:80"]=>
+    array(2) {
+      ["used"]=>
+      int(0)
+      ["free"]=>
+      int(3)
+    }
+  }
+}
+object(stdClass)#%d (2) {
+  ["http\Client\Curl"]=>
+  array(0) {
+  }
+  ["http\Client\Curl\Request"]=>
+  array(1) {
+    ["php.net:80"]=>
+    array(2) {
+      ["used"]=>
+      int(0)
+      ["free"]=>
+      int(0)
+    }
+  }
+}
+Done