Skip to content

Commit 54413a4

Browse files
author
Paul
committed
Added method and content parameters to HttpOptions.
1 parent 9aa5bd4 commit 54413a4

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

src/Porter/Net/Http/HttpOptions.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ public function setQueryParameters(array $queryParameters)
3535
return $this->set('queryParameters', $queryParameters);
3636
}
3737

38+
/**
39+
* @return string
40+
*/
41+
public function getMethod()
42+
{
43+
return $this->get('method');
44+
}
45+
46+
/**
47+
* @param string $method
48+
*
49+
* @return $this
50+
*/
51+
public function setMethod($method)
52+
{
53+
return $this->set('method', "$method");
54+
}
55+
3856
/**
3957
* @return array
4058
*/
@@ -97,10 +115,30 @@ public function findHeaders($name)
97115
});
98116
}
99117

118+
/**
119+
* @return string
120+
*/
121+
public function getContent()
122+
{
123+
return $this->get('content');
124+
}
125+
126+
/**
127+
* @param string $content
128+
*
129+
* @return $this
130+
*/
131+
public function setContent($content)
132+
{
133+
return $this->set('content', "$content");
134+
}
135+
100136
/**
101137
* Extracts a list of HTTP context options only.
102138
*
103139
* @return array HTTP context options.
140+
*
141+
* @see http://php.net/manual/en/context.http.php
104142
*/
105143
public function extractHttpContextOptions()
106144
{

test/Unit/Porter/Net/Http/HttpOptionsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ public function testOptionDefaults()
1313
self::assertSame([], $options->getHeaders());
1414
}
1515

16+
public function testQueryParameters()
17+
{
18+
self::assertSame(
19+
$query = ['foo' => 'bar'],
20+
(new HttpOptions)->setQueryParameters($query)->getQueryParameters()
21+
);
22+
}
23+
24+
public function testMethod()
25+
{
26+
self::assertSame('foo', (new HttpOptions)->setMethod('foo')->getMethod());
27+
}
28+
1629
public function testFindHeader()
1730
{
1831
$options = (new HttpOptions)->addHeader('Foo: bar')->addHeader($baz = 'Baz: bat');
@@ -55,4 +68,9 @@ public function testExtractHttpContextOptions()
5568

5669
self::assertSame(['header' => ['foo']], $options->extractHttpContextOptions());
5770
}
71+
72+
public function testContent()
73+
{
74+
self::assertSame($content = "foo\nbar", (new HttpOptions)->setContent($content)->getContent());
75+
}
5876
}

0 commit comments

Comments
 (0)