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

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zf2 for the canonical source repository
6+
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
* @package Zend_Http
9+
*/
10+
11+
namespace Zend\Http\Header;
12+
13+
/**
14+
* @throws Exception\InvalidArgumentException
15+
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 @todo find section
16+
*/
17+
class ContentTransferEncoding implements HeaderInterface
18+
{
19+
20+
public static function fromString($headerLine)
21+
{
22+
$header = new static();
23+
24+
list($name, $value) = explode(': ', $headerLine, 2);
25+
26+
// check to ensure proper header type for this factory
27+
if (strtolower($name) !== 'content-transfer-encoding') {
28+
throw new Exception\InvalidArgumentException('Invalid header line for Content-Transfer-Encoding string: "' . $name . '"');
29+
}
30+
31+
// @todo implementation details
32+
$header->value = $value;
33+
34+
return $header;
35+
}
36+
37+
public function getFieldName()
38+
{
39+
return 'Content-Transfer-Encoding';
40+
}
41+
42+
public function getFieldValue()
43+
{
44+
return $this->value;
45+
}
46+
47+
public function toString()
48+
{
49+
return 'Content-Transfer-Encoding: ' . $this->getFieldValue();
50+
}
51+
52+
}

src/HeaderLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class HeaderLoader extends PluginClassLoader
4242
'contentlocation' => 'Zend\Http\Header\ContentLocation',
4343
'contentmd5' => 'Zend\Http\Header\ContentMD5',
4444
'contentrange' => 'Zend\Http\Header\ContentRange',
45+
'contenttransferencoding' => 'Zend\Http\Header\ContentTransferEncoding',
4546
'contenttype' => 'Zend\Http\Header\ContentType',
4647
'cookie' => 'Zend\Http\Header\Cookie',
4748
'date' => 'Zend\Http\Header\Date',
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zf2 for the canonical source repository
6+
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
* @package Zend_Http
9+
*/
10+
11+
namespace ZendTest\Http\Header;
12+
13+
use Zend\Http\Header\ContentTransferEncoding;
14+
15+
class ContentTransferEncodingTest extends \PHPUnit_Framework_TestCase
16+
{
17+
18+
public function testContentTransferEncodingFromStringCreatesValidContentTransferEncodingHeader()
19+
{
20+
$contentTransferEncodingHeader = ContentTransferEncoding::fromString('Content-Transfer-Encoding: xxx');
21+
$this->assertInstanceOf('Zend\Http\Header\HeaderInterface', $contentTransferEncodingHeader);
22+
$this->assertInstanceOf('Zend\Http\Header\ContentTransferEncoding', $contentTransferEncodingHeader);
23+
}
24+
25+
public function testContentTransferEncodingGetFieldNameReturnsHeaderName()
26+
{
27+
$contentTransferEncodingHeader = new ContentTransferEncoding();
28+
$this->assertEquals('Content-Transfer-Encoding', $contentTransferEncodingHeader->getFieldName());
29+
}
30+
31+
public function testContentTransferEncodingGetFieldValueReturnsProperValue()
32+
{
33+
$this->markTestIncomplete('ContentTransferEncoding needs to be completed');
34+
35+
$contentTransferEncodingHeader = new ContentTransferEncoding();
36+
$this->assertEquals('xxx', $contentTransferEncodingHeader->getFieldValue());
37+
}
38+
39+
public function testContentTransferEncodingToStringReturnsHeaderFormattedString()
40+
{
41+
$this->markTestIncomplete('ContentTransferEncoding needs to be completed');
42+
43+
$contentTransferEncodingHeader = new ContentTransferEncoding();
44+
45+
// @todo set some values, then test output
46+
$this->assertEmpty('Content-Transfer-Encoding: xxx', $contentTransferEncodingHeader->toString());
47+
}
48+
49+
/** Implmentation specific tests here */
50+
51+
}

0 commit comments

Comments
 (0)