Skip to content

Commit 4d6c63f

Browse files
authored
Added tests with array headers and keys (#10)
* Added tests with array headers and keys * cs
1 parent 0fc0052 commit 4d6c63f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/MessageTrait.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,42 @@ public function testWithAddedHeader()
131131
$this->assertRegExp('|text/html, ?text/plain|', $message->getHeaderLine('Content-Type'));
132132
}
133133

134+
/**
135+
* Make sure we maintain headers when we add array values.
136+
*/
137+
public function testWithAddedHeaderArrayValue()
138+
{
139+
if (isset($this->skippedTests[__FUNCTION__])) {
140+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
141+
}
142+
143+
$message = $this->getMessage()->withAddedHeader('content-type', 'text/html');
144+
$message = $message->withAddedHeader('content-type', ['text/plain', 'application/json']);
145+
146+
$headerLine = $message->getHeaderLine('content-type');
147+
$this->assertRegExp('|text/html|', $headerLine);
148+
$this->assertRegExp('|text/plain|', $headerLine);
149+
$this->assertRegExp('|application/json|', $headerLine);
150+
}
151+
152+
/**
153+
* Make sure we maintain headers when we add array values with keys.
154+
*/
155+
public function testWithAddedHeaderArrayValueAndKeys()
156+
{
157+
if (isset($this->skippedTests[__FUNCTION__])) {
158+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
159+
}
160+
161+
$message = $this->getMessage()->withAddedHeader('content-type', ['foo' => 'text/html']);
162+
$message = $message->withAddedHeader('content-type', ['foo' => 'text/plain', 'bar' => 'application/json']);
163+
164+
$headerLine = $message->getHeaderLine('content-type');
165+
$this->assertRegExp('|text/html|', $headerLine);
166+
$this->assertRegExp('|text/plain|', $headerLine);
167+
$this->assertRegExp('|application/json|', $headerLine);
168+
}
169+
134170
public function testWithoutHeader()
135171
{
136172
if (isset($this->skippedTests[__FUNCTION__])) {

0 commit comments

Comments
 (0)