add pecl/http-v2 tests; release 1.0.3
[m6w6/ext-raphf] / tests / http004.phpt
1 --TEST--
2 pecl/http-v2 - partial clean
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 var_dump(raphf\stat_persistent_handles());
17
18 $c = new http\Client("curl", "php.net:80");
19 $c2 = new http\Client("curl", "php.net:80");
20 do {
21 $c->enqueue(new http\Client\Request("GET", "http://php.net"));
22 $c2->enqueue(new http\Client\Request("GET", "http://php.net"));
23 } while (count($c) < 3);
24
25 var_dump(raphf\stat_persistent_handles());
26
27 unset($c);
28
29 var_dump(raphf\stat_persistent_handles());
30
31 raphf\clean_persistent_handles();
32
33 var_dump(raphf\stat_persistent_handles());
34
35 ?>
36 Done
37 --EXPECTF--
38 Test
39 object(stdClass)#%d (2) {
40 ["http\Client\Curl"]=>
41 array(0) {
42 }
43 ["http\Client\Curl\Request"]=>
44 array(0) {
45 }
46 }
47 object(stdClass)#%d (2) {
48 ["http\Client\Curl"]=>
49 array(1) {
50 ["php.net:80"]=>
51 array(2) {
52 ["used"]=>
53 int(2)
54 ["free"]=>
55 int(0)
56 }
57 }
58 ["http\Client\Curl\Request"]=>
59 array(1) {
60 ["php.net:80"]=>
61 array(2) {
62 ["used"]=>
63 int(6)
64 ["free"]=>
65 int(0)
66 }
67 }
68 }
69 object(stdClass)#%d (2) {
70 ["http\Client\Curl"]=>
71 array(1) {
72 ["php.net:80"]=>
73 array(2) {
74 ["used"]=>
75 int(1)
76 ["free"]=>
77 int(1)
78 }
79 }
80 ["http\Client\Curl\Request"]=>
81 array(1) {
82 ["php.net:80"]=>
83 array(2) {
84 ["used"]=>
85 int(3)
86 ["free"]=>
87 int(3)
88 }
89 }
90 }
91 object(stdClass)#%d (2) {
92 ["http\Client\Curl"]=>
93 array(1) {
94 ["php.net:80"]=>
95 array(2) {
96 ["used"]=>
97 int(1)
98 ["free"]=>
99 int(0)
100 }
101 }
102 ["http\Client\Curl\Request"]=>
103 array(1) {
104 ["php.net:80"]=>
105 array(2) {
106 ["used"]=>
107 int(3)
108 ["free"]=>
109 int(0)
110 }
111 }
112 }
113 Done