Passed
Push — master ( 61f9d3...13d852 )
by mon
01:42
created

testGetStrictTypesUnknownExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace FileEye\MimeMap\Test;
4
5
use FileEye\MimeMap\Extension;
6
7
class ExtensionTest extends MimeMapTestBase
8
{
9
    public function testGetDefaultType()
10
    {
11
        $this->assertSame('text/plain', (new Extension('txt'))->getDefaultType());
12
        $this->assertSame('text/plain', (new Extension('TXT'))->getDefaultType());
13
        $this->assertSame('image/png', (new Extension('png'))->getDefaultType());
14
        $this->assertSame('application/vnd.oasis.opendocument.text', (new Extension('odt'))->getDefaultType());
15
    }
16
17
    /**
18
     * @expectedException \FileEye\MimeMap\MappingException
19
     */
20
    public function testGetStrictDefaultTypeUnknownExtension()
21
    {
22
        $this->assertSame('application/octet-stream', (new Extension('ohmygodthatisnoextension'))->getDefaultType());
23
    }
24
25
    public function testGetNoStrictDefaultTypeUnknownExtension()
26
    {
27
        $this->assertSame('application/octet-stream', (new Extension('ohmygodthatisnoextension'))->getDefaultType(false));
28
    }
29
30
    public function testGetTypes()
31
    {
32
        $this->assertSame(['text/vnd.dvb.subtitle', 'image/vnd.dvb.subtitle', 'text/x-microdvd', 'text/x-mpsub', 'text/x-subviewer'], (new Extension('sub'))->getTypes());
33
        $this->assertSame(['text/vnd.dvb.subtitle', 'image/vnd.dvb.subtitle', 'text/x-microdvd', 'text/x-mpsub', 'text/x-subviewer'], (new Extension('sUb'))->getTypes());
34
    }
35
36
    /**
37
     * @expectedException \FileEye\MimeMap\MappingException
38
     */
39
    public function testGetStrictTypesUnknownExtension()
40
    {
41
        $this->assertSame(['application/octet-stream'], (new Extension('ohmygodthatisnoextension'))->getTypes());
42
    }
43
44
    public function testGetNoStrictTypesUnknownExtension()
45
    {
46
        $this->assertSame(['application/octet-stream'], (new Extension('ohmygodthatisnoextension'))->getTypes(false));
47
    }
48
}
49