fix #98 #99 #100 #101 #102 #103
[m6w6/ext-http] / tests / client010.phpt
1 --TEST--
2 client upload
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 skip_client_test();
7 ?>
8 --FILE--
9 <?php
10
11 include "helper/server.inc";
12
13 echo "Test\n";
14 $RE =
15 '/(Array
16 \(
17 \[upload\] \=\> Array
18 \(
19 \[name\] \=\> client010\.php
20 \[type\] \=\> text\/plain
21 \[size\] \=\> \d+
22 \)
23
24 \)
25 )+/';
26
27 server("env.inc", function($port) use($RE) {
28
29 $request = new http\Client\Request("POST", "http://localhost:$port");
30 $request->getBody()->addForm(null, array("file"=>__FILE__, "name"=>"upload", "type"=>"text/plain"));
31
32 foreach (http\Client::getAvailableDrivers() as $driver) {
33 $client = new http\Client($driver);
34 $client->enqueue($request)->send();
35 if (!preg_match($RE, $s = $client->getResponse()->getBody()->toString())) {
36 echo($s);
37 }
38 }
39 });
40 ?>
41 Done
42 --EXPECT--
43 Test
44 Done