ContentDispositionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 3
c 4
b 0
f 1
lcom 0
cbo 1
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testParsingSimpleEntry() 0 8 1
A testFileUploadEntry() 0 8 1
A testGivenName() 0 5 1
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