50dbb1c4a52fb5f84511c02ad0f1f6199ba2e274
[m6w6/ext-raphf] / tests / http003.phpt
1 --TEST--
2 pecl/http-v2 - clean with id only
3 --SKIPIF--
4 <?php
5 if (!extension_loaded("http")) {
6 die("skip pecl/http needed");
7 }
8 if (!class_exists("http\\Client", false)) {
9 die("skip pecl/http-v2 with curl support needed");
10 }
11 ?>
12 --FILE--
13 <?php
14 echo "Test\n";
15
16 $c = new http\Client("curl", "php.net:80");
17 do {
18 $c->enqueue(new http\Client\Request("GET", "http://php.net"));
19 } while (count($c) < 3);
20
21 unset($c);
22
23 $h = (array) raphf\stat_persistent_handles();
24 var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
25
26 raphf\clean_persistent_handles(null, "php.net:80");
27
28 $h = (array) raphf\stat_persistent_handles();
29 var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
30
31 ?>
32 Done
33 --EXPECTF--
34 Test
35 array(2) {
36 ["http\Client\Curl"]=>
37 array(1) {
38 ["php.net:80"]=>
39 array(2) {
40 ["used"]=>
41 int(0)
42 ["free"]=>
43 int(1)
44 }
45 }
46 ["http\Client\Curl\Request"]=>
47 array(1) {
48 ["php.net:80"]=>
49 array(2) {
50 ["used"]=>
51 int(0)
52 ["free"]=>
53 int(3)
54 }
55 }
56 }
57 array(2) {
58 ["http\Client\Curl"]=>
59 array(1) {
60 ["php.net:80"]=>
61 array(2) {
62 ["used"]=>
63 int(0)
64 ["free"]=>
65 int(0)
66 }
67 }
68 ["http\Client\Curl\Request"]=>
69 array(1) {
70 ["php.net:80"]=>
71 array(2) {
72 ["used"]=>
73 int(0)
74 ["free"]=>
75 int(0)
76 }
77 }
78 }
79 Done