diff --git a/src/Porter/Net/Http/HttpOptions.php b/src/Porter/Net/Http/HttpOptions.php index e6be735..923e8e2 100644 --- a/src/Porter/Net/Http/HttpOptions.php +++ b/src/Porter/Net/Http/HttpOptions.php @@ -35,6 +35,24 @@ public function setQueryParameters(array $queryParameters) return $this->set('queryParameters', $queryParameters); } + /** + * @return string + */ + public function getMethod() + { + return $this->get('method'); + } + + /** + * @param string $method + * + * @return $this + */ + public function setMethod($method) + { + return $this->set('method', "$method"); + } + /** * @return array */ @@ -97,10 +115,30 @@ public function findHeaders($name) }); } + /** + * @return string + */ + public function getContent() + { + return $this->get('content'); + } + + /** + * @param string $content + * + * @return $this + */ + public function setContent($content) + { + return $this->set('content', "$content"); + } + /** * Extracts a list of HTTP context options only. * * @return array HTTP context options. + * + * @see http://php.net/manual/en/context.http.php */ public function extractHttpContextOptions() { diff --git a/test/Unit/Porter/Net/Http/HttpOptionsTest.php b/test/Unit/Porter/Net/Http/HttpOptionsTest.php index 495b4c7..d6c8fed 100644 --- a/test/Unit/Porter/Net/Http/HttpOptionsTest.php +++ b/test/Unit/Porter/Net/Http/HttpOptionsTest.php @@ -13,6 +13,19 @@ public function testOptionDefaults() self::assertSame([], $options->getHeaders()); } + public function testQueryParameters() + { + self::assertSame( + $query = ['foo' => 'bar'], + (new HttpOptions)->setQueryParameters($query)->getQueryParameters() + ); + } + + public function testMethod() + { + self::assertSame('foo', (new HttpOptions)->setMethod('foo')->getMethod()); + } + public function testFindHeader() { $options = (new HttpOptions)->addHeader('Foo: bar')->addHeader($baz = 'Baz: bat'); @@ -55,4 +68,9 @@ public function testExtractHttpContextOptions() self::assertSame(['header' => ['foo']], $options->extractHttpContextOptions()); } + + public function testContent() + { + self::assertSame($content = "foo\nbar", (new HttpOptions)->setContent($content)->getContent()); + } }