1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Fracture\Http\Headers; |
5
|
|
|
|
6
|
|
|
use Exception; |
7
|
|
|
use ReflectionClass; |
8
|
|
|
use PHPUnit_Framework_TestCase; |
9
|
|
|
|
10
|
|
|
class ContentDispositionTest extends PHPUnit_Framework_TestCase |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::__construct |
15
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::prepare |
16
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::extractData |
17
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::getAttribute |
18
|
|
|
*/ |
19
|
|
|
public function testParsingSimpleEntry() |
20
|
|
|
{ |
21
|
|
|
$instance = new ContentDisposition('form-data; name="text"'); |
22
|
|
|
$instance->prepare(); |
23
|
|
|
|
24
|
|
|
$this->assertEquals('text', $instance->getAttribute('name')); |
25
|
|
|
$this->assertNull($instance->getAttribute('fake')); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::__construct |
31
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::prepare |
32
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::extractData |
33
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::getAttribute |
34
|
|
|
*/ |
35
|
|
|
public function testFileUploadEntry() |
36
|
|
|
{ |
37
|
|
|
$instance = new ContentDisposition('form-data; name="file"; filename="file-simple.png"'); |
38
|
|
|
$instance->prepare(); |
39
|
|
|
|
40
|
|
|
$this->assertEquals('file', $instance->getAttribute('name')); |
41
|
|
|
$this->assertEquals('file-simple.png', $instance->getAttribute('filename')); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::__construct |
47
|
|
|
* @covers Fracture\Http\Headers\ContentDisposition::getName |
48
|
|
|
*/ |
49
|
|
|
public function testGivenName() |
50
|
|
|
{ |
51
|
|
|
$instance = new ContentDisposition; |
52
|
|
|
$this->assertSame('Content-Disposition', $instance->getName()); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|