Overrides lithium\net\http\Request::to() to provide the correct options for generating
URLs. For information about this method, see the parent implementation.
/** * Tests that `action\Request` correctly inherits the functionality of the `to()` method * inherited from `lithium\net\http\Request`. */ public function testConvertToUrl() { $request = new Request(array('env' => array('HTTP_HOST' => 'foo.com', 'HTTPS' => 'on'), 'base' => '/the/base/path', 'url' => '/the/url', 'query' => array('some' => 'query', 'parameter' => 'values'))); $expected = 'https://foo.com/the/base/path/the/url?some=query¶meter=values'; $this->assertEqual($expected, $request->to('url')); }
public function testConvertToStringWithJson() { $expected = join("\r\n", array('GET /posts HTTP/1.1', 'Host: lithify.me', 'Connection: Close', 'User-Agent: Mozilla/5.0', 'Content-Type: application/json', 'Content-Length: 36', '', '{"some":"body","parameter":"values"}')); $request = new Request(array('env' => array('HTTP_HOST' => 'lithify.me', 'CONTENT_TYPE' => 'application/json', 'HTTP_USER_AGENT' => 'Mozilla/5.0'), 'url' => '/posts', 'body' => '{"some":"body","parameter":"values"}')); $this->assertEqual($expected, $request->to('string')); $request = new Request(array('env' => array('HTTP_HOST' => 'lithify.me', 'CONTENT_TYPE' => 'application/json', 'HTTP_USER_AGENT' => 'Mozilla/5.0'), 'url' => '/posts', 'data' => array('some' => 'body', 'parameter' => 'values'))); $this->assertEqual($expected, $request->to('string')); }