Passed
Push — master ( c11447...ba145f )
by mon
02:14
created

testGetStrictTypesUnknownExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace FileEye\MimeMap\Test;
4
5
use FileEye\MimeMap\Extension;
6
use FileEye\MimeMap\MappingException;
7
8
class ExtensionTest extends MimeMapTestBase
9
{
10
    public function testGetDefaultType(): void
11
    {
12
        $this->assertSame('text/plain', (new Extension('txt'))->getDefaultType());
13
        $this->assertSame('text/plain', (new Extension('TXT'))->getDefaultType());
14
        $this->assertSame('image/png', (new Extension('png'))->getDefaultType());
15
        $this->assertSame('application/vnd.oasis.opendocument.text', (new Extension('odt'))->getDefaultType());
16
    }
17
18
    public function testGetStrictDefaultTypeUnknownExtension(): void
19
    {
20
        $this->expectException(MappingException::class);
21
        $this->expectExceptionMessage("No MIME type mapped to extension ohmygodthatisnoextension");
22
        $this->assertSame('application/octet-stream', (new Extension('ohmygodthatisnoextension'))->getDefaultType());
23
    }
24
25
    public function testGetTypes(): void
26
    {
27
        $this->assertSame(['text/vnd.dvb.subtitle', 'image/vnd.dvb.subtitle', 'text/x-microdvd', 'text/x-mpsub', 'text/x-subviewer'], (new Extension('sub'))->getTypes());
28
        $this->assertSame(['text/vnd.dvb.subtitle', 'image/vnd.dvb.subtitle', 'text/x-microdvd', 'text/x-mpsub', 'text/x-subviewer'], (new Extension('sUb'))->getTypes());
29
    }
30
31
    public function testGetStrictTypesUnknownExtension(): void
32
    {
33
        $this->expectException(MappingException::class);
34
        $this->expectExceptionMessage("No MIME type mapped to extension ohmygodthatisnoextension");
35
        $this->assertSame(['application/octet-stream'], (new Extension('ohmygodthatisnoextension'))->getTypes());
36
    }
37
}
38