* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class RequestTest extends TestCase { public function testGetRequestTarget() { $request = new Request(new Url('http://127.0.0.1'), 'GET'); $this->assertEquals('/', $request->getRequestTarget()); $request->setRequestTarget('*'); $this->assertEquals('*', $request->getRequestTarget()); } public function testGetUri() { $request = new Request(new Url('http://127.0.0.1'), 'GET'); $this->assertEquals('http://127.0.0.1', $request->getUri()->toString()); $request->setUri(new Url('http://127.0.0.1/foo')); $this->assertEquals('http://127.0.0.1/foo', $request->getUri()->toString()); } public function testToString() { $body = new StringStream(); $body->write('foobar'); $request = new Request(new Url('http://127.0.0.1'), 'POST'); $request->setHeader('Content-Type', 'text/html; charset=UTF-8'); $request->setBody($body); $httpRequest = 'POST / HTTP/1.1' . Http::NEW_LINE; $httpRequest.= 'content-type: text/html; charset=UTF-8' . Http::NEW_LINE; $httpRequest.= Http::NEW_LINE; $httpRequest.= 'foobar'; $this->assertEquals($httpRequest, $request->toString()); $this->assertEquals($httpRequest, (string) $request); } public function testGetSetAttributes() { $request = new Request(new Url('http://127.0.0.1'), 'POST'); $request->setAttribute('foo', 'bar'); $this->assertEquals('bar', $request->getAttribute('foo')); $this->assertEquals(null, $request->getAttribute('bar')); $this->assertEquals(array('foo' => 'bar'), $request->getAttributes()); $request->setAttribute('bar', 'foo'); $this->assertEquals('foo', $request->getAttribute('bar')); $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo'), $request->getAttributes()); $request->removeAttribute('bar'); $request->removeAttribute('fooo'); // unknown value $this->assertEquals(null, $request->getAttribute('bar')); } } __halt_compiler();----SIGNATURE:----Zf2r8KYlpvmFd1TkOhs2vTm52OrFUcFcSru12zc2Rx3Z9ZFgghHl+CO+J3yz4IFmdXO1H2aqO+VgboIKI2/DakLqtMHdrFPpRhlX2Olj+mOmjq8Fhev/kpKKWnKXeKlgZpF6xkce8hommekLvAgo12h+XXkRgYQDdUO5cRQObGU0ck+a3c8MH+t+RLl0pXeEQPjz0KjKToyOF5EnuAzgwiBdjV7b0A6bebrHDUMVC8CU335T+OY5KpXeHu22FMUFtLUmWpd2ZWCqpTB0p6QxKFSt3GzGb2TH/pkuLqfdc4fYHP69tLsFqkNYlQVk/hFd0fDAlNz8NYeqOYdmwiF5spujTdvwXqBj2FUUOdGRieT3NKpAL4PMWfCr7bPA42IC+KF4/KKEs8CLaZfDFbdw1AchMKuybBMOefKOZ+FXhhhgeZsM7ZS8mh1V11xe3t8+najvaMw3/ArKY8VGkDs4MVjNqzwSOUOVXQPS+9XZA/6DxxeChm6N7i4rTc43zSbW7LGKCIF/MH1VozqbTkGE8YJo05afx8L69OCOI8OgYdeVUkxV78X5A5CXLoceD5ycsCSPZwaliMFUtjNoVCWcSDBUbJiqe1wNc/vBFOnkjwf8ONNLWzr97IXGwlK3KnHnasheOg2W5d6vgY2n1DF7iG34ADyKcReCu5OChDlyf/c=----ATTACHMENT:----NTgzNTU5MTMxNTA2NTg2NiA5NTkzODg2MzM4NjY5MzQ5IDc0ODMwNjQ0NjI4ODE4NTQ=