Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/zendframework/zendframework#6484-zend-http-origi…
Browse files Browse the repository at this point in the history
…n-header-instantiation'

Close zendframework/zendframework#6484
  • Loading branch information
Ocramius committed Aug 6, 2014
5 parents e6cd592 + 2aef442 + 5f5970f + 3ff9149 + d1e784e commit b6a3bf2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
17 changes: 10 additions & 7 deletions src/Header/Origin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ class Origin implements HeaderInterface
/**
* @var string
*/
private $value;

protected $value;
public static function fromString($headerLine)
{
$header = new static();

list($name, $value) = explode(': ', $headerLine, 2);

// check to ensure proper header type for this factory
Expand All @@ -38,10 +36,15 @@ public static function fromString($headerLine)
throw new Exception\InvalidArgumentException('Invalid header value for Origin key: "' . $name . '"');
}

// @todo implementation details
$header->value = $value;
return new static($value);
}

return $header;
/**
* @param string|null $value
*/
public function __construct($value = null)
{
$this->value = (string) $value;
}

public function getFieldName()
Expand Down
24 changes: 11 additions & 13 deletions test/Header/OriginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@

class OriginTest extends \PHPUnit_Framework_TestCase
{
/**
* @group 6484
*/
public function testOriginFieldValueIsAlwaysAString()
{
$origin = new Origin();

$this->assertInternalType('string', $origin->getFieldValue());
}

public function testOriginFromStringCreatesValidOriginHeader()
{
$OriginHeader = Origin::fromString('Origin: http://zend.org');
Expand All @@ -28,19 +38,7 @@ public function testOriginGetFieldNameReturnsHeaderName()

public function testOriginGetFieldValueReturnsProperValue()
{
$this->markTestIncomplete('Origin needs to be completed');

$OriginHeader = new Origin();
$OriginHeader = Origin::fromString('Origin: http://zend.org');
$this->assertEquals('http://zend.org', $OriginHeader->getFieldValue());
}

public function testOriginToStringReturnsHeaderFormattedString()
{
$this->markTestIncomplete('Origin needs to be completed');

$OriginHeader = new Origin();

// @todo set some values, then test output
$this->assertEmpty('Origin: http://zend.org', $OriginHeader->toString());
}
}

0 comments on commit b6a3bf2

Please sign in to comment.