|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Fracture\Http\Headers; |
|
5
|
|
|
|
|
6
|
|
|
use Exception; |
|
7
|
|
|
use ReflectionClass; |
|
8
|
|
|
use PHPUnit_Framework_TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class CommonTest extends PHPUnit_Framework_TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
15
|
|
|
* @covers Fracture\Http\Headers\Common::isFinal |
|
16
|
|
|
*/ |
|
17
|
|
|
public function testIsFinalResponse() |
|
18
|
|
|
{ |
|
19
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common'); |
|
20
|
|
|
$this->assertFalse($instance->isFinal()); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
25
|
|
|
* @covers Fracture\Http\Headers\Common::getValue |
|
26
|
|
|
*/ |
|
27
|
|
|
public function testDefaultInstantiation() |
|
28
|
|
|
{ |
|
29
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common'); |
|
30
|
|
|
$this->assertSame('', $instance->getValue()); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
35
|
|
|
* @covers Fracture\Http\Headers\Common::getValue |
|
36
|
|
|
*/ |
|
37
|
|
|
public function testStandardInstantiation() |
|
38
|
|
|
{ |
|
39
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common', ['alpha']); |
|
40
|
|
|
$this->assertSame('alpha', $instance->getValue()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
46
|
|
|
* @covers Fracture\Http\Headers\Common::setValue |
|
47
|
|
|
* @covers Fracture\Http\Headers\Common::getValue |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testStandardAlteration() |
|
50
|
|
|
{ |
|
51
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common', ['']); |
|
52
|
|
|
$instance->setValue('beta'); |
|
53
|
|
|
$this->assertSame('beta', $instance->getValue()); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
59
|
|
|
* @covers Fracture\Http\Headers\Common::getName |
|
60
|
|
|
*/ |
|
61
|
|
|
public function testNameValue() |
|
62
|
|
|
{ |
|
63
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common', ['']); |
|
64
|
|
|
$this->assertSame('Unspecified', $instance->getName()); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
70
|
|
|
* @covers Fracture\Http\Headers\Common::getParsedData |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testParsedDataForUnpreparedInstance() |
|
73
|
|
|
{ |
|
74
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common'); |
|
75
|
|
|
$this->assertNull($instance->getParsedData()); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
81
|
|
|
* @covers Fracture\Http\Headers\Common::prepare |
|
82
|
|
|
* @covers Fracture\Http\Headers\Common::getParsedData |
|
83
|
|
|
*/ |
|
84
|
|
|
public function testParsedDataForPreparedInstanceWithNoValueSet() |
|
85
|
|
|
{ |
|
86
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common'); |
|
87
|
|
|
$instance->prepare(); |
|
88
|
|
|
$this->assertNull($instance->getParsedData()); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
94
|
|
|
* @covers Fracture\Http\Headers\Common::prepare |
|
95
|
|
|
* @covers Fracture\Http\Headers\Common::getParsedData |
|
96
|
|
|
*/ |
|
97
|
|
|
public function testParsedDataForPreparedInstance() |
|
98
|
|
|
{ |
|
99
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common', ['alpha']); |
|
100
|
|
|
$instance->expects($this->any()) |
|
101
|
|
|
->method('extractData') |
|
102
|
|
|
->will($this->returnValue('beta')); |
|
103
|
|
|
|
|
104
|
|
|
$instance->prepare(); |
|
105
|
|
|
$this->assertSame('beta', $instance->getParsedData()); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @covers Fracture\Http\Headers\Common::__construct |
|
111
|
|
|
* @covers Fracture\Http\Headers\Common::prepare |
|
112
|
|
|
* @covers Fracture\Http\Headers\Common::getParsedData |
|
113
|
|
|
* @covers Fracture\Http\Headers\Common::getParameter |
|
114
|
|
|
*/ |
|
115
|
|
|
public function testValueRetrieval() |
|
116
|
|
|
{ |
|
117
|
|
|
$instance = $this->getMockForAbstractClass('Fracture\Http\Headers\Common', ['type/subtype; name=4']); |
|
118
|
|
|
$instance->expects($this->any()) |
|
119
|
|
|
->method('extractData') |
|
120
|
|
|
->will($this->returnValue(['name' => 4])); |
|
121
|
|
|
|
|
122
|
|
|
$instance->prepare(); |
|
123
|
|
|
$this->assertSame(4, $instance->getParameter('name')); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|