prepare v4.2.5
[m6w6/ext-http] / tests / client009.phpt
1 --TEST--
2 client static cookies
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
15 function x($a) {
16 $r[key($a)]=end($a);
17 $r[key($a)]=reset($a);
18 return $r;
19 }
20
21 server("env.inc", function($port) {
22 $client = new http\Client;
23 $client->setCookies(array("test" => "bar"));
24 $client->addCookies(array("foo" => "test"));
25
26 $request = new http\Client\Request("GET", "http://localhost:$port");
27 $client->enqueue($request);
28 $client->send();
29 echo $client->getResponse()->getBody()->toString();
30
31 $request->setOptions(array("cookies" => x($client->getCookies())));
32 $client->requeue($request);
33 $client->send();
34
35 echo $client->getResponse()->getBody()->toString();
36 });
37 ?>
38 Done
39 --EXPECT--
40 Test
41 Array
42 (
43 [test] => bar
44 [foo] => test
45 )
46 Array
47 (
48 [test] => test
49 [foo] => bar
50 )
51 Done