public function testConstructorInitializesMessage() { $r = new puzzle_message_Request('PUT', '/test', array('test' => '123'), puzzle_stream_Stream::factory('foo')); $this->assertEquals('PUT', $r->getMethod()); $this->assertEquals('/test', $r->getUrl()); $this->assertEquals('123', $r->getHeader('test')); $this->assertEquals('foo', $r->getBody()); }
public function testCanRemoveBodyBySettingToNullAndRemovesCommonBodyHeaders() { $m = new puzzle_message_Request('GET', 'http://foo.com'); $m->setBody(puzzle_stream_Stream::factory('foo')); $m->setHeader('Content-Length', 3)->setHeader('Transfer-Encoding', 'chunked'); $m->setBody(null); $this->assertNull($m->getBody()); $this->assertFalse($m->hasHeader('Content-Length')); $this->assertFalse($m->hasHeader('Transfer-Encoding')); }