travis
[m6w6/ext-raphf] / tests / http001.phpt
1 --TEST--
2 pecl/http-v2 - general and stat
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 $h = (array) raphf\stat_persistent_handles();
17 var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
18
19 $c = new http\Client("curl", "PHP");
20 do {
21 $c->enqueue(new http\Client\Request("GET", "http://php.net"));
22 } while (count($c) < 3);
23
24 $h = (array) raphf\stat_persistent_handles();
25 var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
26
27 unset($c);
28
29 $h = (array) raphf\stat_persistent_handles();
30 var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
31
32 ?>
33 Done
34 --EXPECTF--
35 Test
36 array(2) {
37 ["http\Client\Curl"]=>
38 array(0) {
39 }
40 ["http\Client\Curl\Request"]=>
41 array(0) {
42 }
43 }
44 array(2) {
45 ["http\Client\Curl"]=>
46 array(1) {
47 ["PHP"]=>
48 array(2) {
49 ["used"]=>
50 int(1)
51 ["free"]=>
52 int(0)
53 }
54 }
55 ["http\Client\Curl\Request"]=>
56 array(1) {
57 ["PHP:php.net:80"]=>
58 array(2) {
59 ["used"]=>
60 int(3)
61 ["free"]=>
62 int(0)
63 }
64 }
65 }
66 array(2) {
67 ["http\Client\Curl"]=>
68 array(1) {
69 ["PHP"]=>
70 array(2) {
71 ["used"]=>
72 int(0)
73 ["free"]=>
74 int(1)
75 }
76 }
77 ["http\Client\Curl\Request"]=>
78 array(1) {
79 ["PHP:php.net:80"]=>
80 array(2) {
81 ["used"]=>
82 int(0)
83 ["free"]=>
84 int(3)
85 }
86 }
87 }
88 Done