Message::getHeaderLine returns an empty string when the header is not set.

This commit is contained in:
PJ Dietz 2015-04-29 07:42:40 -04:00
parent 5eb30ccafb
commit 2e7783d19d
2 changed files with 6 additions and 6 deletions

View File

@ -158,19 +158,19 @@ abstract class Message implements MessageInterface
* and supply your own delimiter when concatenating. * and supply your own delimiter when concatenating.
* *
* If the header does not appear in the message, this method MUST return * If the header does not appear in the message, this method MUST return
* a null value. * an empty string.
* *
* @param string $name Case-insensitive header field name. * @param string $name Case-insensitive header field name.
* @return string|null A string of values as provided for the given header * @return string A string of values as provided for the given header
* concatenated together using a comma. If the header does not appear in * concatenated together using a comma. If the header does not appear in
* the message, this method MUST return a null value. * the message, this method MUST return an empty string.
*/ */
public function getHeaderLine($name) public function getHeaderLine($name)
{ {
if (isset($this->headers[$name])) { if (isset($this->headers[$name])) {
return join(", ", $this->headers[$name]); return join(", ", $this->headers[$name]);
} else { } else {
return null; return "";
} }
} }

View File

@ -186,10 +186,10 @@ class MessageTest extends \PHPUnit_Framework_TestCase
/** /**
* @covers WellRESTed\Message\Message::getHeaderLine * @covers WellRESTed\Message\Message::getHeaderLine
*/ */
public function testGetHeaderLineReturnsNullForUnsetHeader() public function testGetHeaderLineReturnsEmptyStringForUnsetHeader()
{ {
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message'); $message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
$this->assertNull($message->getHeaderLine("X-not-set")); $this->assertSame("", $message->getHeaderLine("X-not-set"));
} }
/** /**