forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Http | ||
*/ | ||
|
||
namespace Zend\Http\Header; | ||
|
||
/** | ||
* @throws Exception\InvalidArgumentException | ||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 @todo find section | ||
*/ | ||
class ContentTransferEncoding implements HeaderInterface | ||
{ | ||
|
||
public static function fromString($headerLine) | ||
{ | ||
$header = new static(); | ||
|
||
list($name, $value) = explode(': ', $headerLine, 2); | ||
|
||
// check to ensure proper header type for this factory | ||
if (strtolower($name) !== 'content-transfer-encoding') { | ||
throw new Exception\InvalidArgumentException('Invalid header line for Content-Transfer-Encoding string: "' . $name . '"'); | ||
} | ||
|
||
// @todo implementation details | ||
$header->value = $value; | ||
|
||
return $header; | ||
} | ||
|
||
public function getFieldName() | ||
{ | ||
return 'Content-Transfer-Encoding'; | ||
} | ||
|
||
public function getFieldValue() | ||
{ | ||
return $this->value; | ||
} | ||
|
||
public function toString() | ||
{ | ||
return 'Content-Transfer-Encoding: ' . $this->getFieldValue(); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
tests/ZendTest/Http/Header/ContentTransferEncodingTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Http | ||
*/ | ||
|
||
namespace ZendTest\Http\Header; | ||
|
||
use Zend\Http\Header\ContentTransferEncoding; | ||
|
||
class ContentTransferEncodingTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testContentTransferEncodingFromStringCreatesValidContentTransferEncodingHeader() | ||
{ | ||
$contentTransferEncodingHeader = ContentTransferEncoding::fromString('Content-Transfer-Encoding: xxx'); | ||
$this->assertInstanceOf('Zend\Http\Header\HeaderInterface', $contentTransferEncodingHeader); | ||
$this->assertInstanceOf('Zend\Http\Header\ContentTransferEncoding', $contentTransferEncodingHeader); | ||
} | ||
|
||
public function testContentTransferEncodingGetFieldNameReturnsHeaderName() | ||
{ | ||
$contentTransferEncodingHeader = new ContentTransferEncoding(); | ||
$this->assertEquals('Content-Transfer-Encoding', $contentTransferEncodingHeader->getFieldName()); | ||
} | ||
|
||
public function testContentTransferEncodingGetFieldValueReturnsProperValue() | ||
{ | ||
$this->markTestIncomplete('ContentTransferEncoding needs to be completed'); | ||
|
||
$contentTransferEncodingHeader = new ContentTransferEncoding(); | ||
$this->assertEquals('xxx', $contentTransferEncodingHeader->getFieldValue()); | ||
} | ||
|
||
public function testContentTransferEncodingToStringReturnsHeaderFormattedString() | ||
{ | ||
$this->markTestIncomplete('ContentTransferEncoding needs to be completed'); | ||
|
||
$contentTransferEncodingHeader = new ContentTransferEncoding(); | ||
|
||
// @todo set some values, then test output | ||
$this->assertEmpty('Content-Transfer-Encoding: xxx', $contentTransferEncodingHeader->toString()); | ||
} | ||
|
||
/** Implmentation specific tests here */ | ||
|
||
} |