12 class message extends http\Message {
13 function __call($m, $args) {
14 if (preg_match("/^test(get|set)(.*)\$/i", $m, $match)) {
15 list(, $getset, $prop) = $match;
16 $prop = strtolower($prop[0]).substr($prop,1);
17 switch(strtolower($getset)) {
21 $this->$prop = current($args);
29 var_dump(0 === $test->testGetType());
30 var_dump(null === $test->testGetBody());
31 var_dump(null === $test->testGetRequestMethod());
32 var_dump(null === $test->testGetRequestUrl());
33 var_dump(null === $test->testGetResponseStatus());
34 var_dump(null === $test->testGetResponseCode());
35 var_dump("1.1" === $test->testGetHttpVersion());
36 var_dump(array() === $test->testGetHeaders());
37 var_dump(null === $test->testGetParentMessage());
38 $test->testSetType(http\Message::TYPE_REQUEST);
39 var_dump(http\Message::TYPE_REQUEST === $test->testGetType());
40 var_dump(http\Message::TYPE_REQUEST === $test->getType());
41 $body = new http\Message\Body;
42 $test->testSetBody($body);
43 var_dump($body === $test->testGetBody());
44 var_dump($body === $test->getBody());
45 $file = fopen(__FILE__,"r");
46 $test->testSetBody($file);
47 var_dump($file === $test->testGetBody()->getResource());
48 var_dump($file === $test->getBody()->getResource());
49 $test->testSetBody("data");
50 var_dump("data" === (string) $test->testGetBody());
51 var_dump("data" === (string) $test->getBody());
52 $test->testSetRequestMethod("HEAD");
53 var_dump("HEAD" === $test->testGetRequestMethod());
54 var_dump("HEAD" === $test->getRequestMethod());
55 $test->testSetRequestUrl("/");
56 var_dump("/" === $test->testGetRequestUrl());
57 var_dump("/" === $test->getRequestUrl());
58 var_dump("HEAD / HTTP/1.1" === $test->getInfo());
59 $test->testSetType(http\Message::TYPE_RESPONSE);
60 $test->setResponseStatus("Created");
61 var_dump("Created" === $test->testGetResponseStatus());
62 var_dump("Created" === $test->getResponseStatus());
63 $test->setResponseCode(201);
64 var_dump(201 === $test->testGetResponseCode());
65 var_dump(201 === $test->getResponseCode());
66 $test->testSetResponseStatus("Ok");
67 var_dump("Ok" === $test->testGetResponseStatus());
68 var_dump("Ok" === $test->getResponseStatus());
69 $test->testSetResponseCode(200);
70 var_dump(200 === $test->testGetResponseCode());
71 var_dump(200 === $test->getResponseCode());
72 $test->testSetHttpVersion("1.0");
73 var_dump("1.0" === $test->testGetHttpVersion());
74 var_dump("1.0" === $test->getHttpVersion());
75 var_dump("HTTP/1.0 200 OK" === $test->getInfo());
76 $test->setHttpVersion("1.1");
77 var_dump("1.1" === $test->testGetHttpVersion());
78 var_dump("1.1" === $test->getHttpVersion());
79 var_dump("HTTP/1.1 200 OK" === $test->getInfo());
80 $test->setInfo("HTTP/1.1 201 Created");
81 var_dump("Created" === $test->testGetResponseStatus());
82 var_dump("Created" === $test->getResponseStatus());
83 var_dump(201 === $test->testGetResponseCode());
84 var_dump(201 === $test->getResponseCode());
85 var_dump("1.1" === $test->testGetHttpVersion());
86 var_dump("1.1" === $test->getHttpVersion());
87 $test->testSetHeaders(array("Foo" => "bar"));
88 var_dump(array("Foo" => "bar") === $test->testGetHeaders());
89 var_dump(array("Foo" => "bar") === $test->getHeaders());
90 var_dump("bar" === $test->getHeader("foo"));
91 var_dump(false === $test->getHeader("bar"));
92 $parent = new message;
93 $test->testSetParentMessage($parent);
94 var_dump($parent === $test->testGetParentMessage());
95 var_dump($parent === $test->getParentMessage());