Passed
Pull Request — master (#3)
by mon
02:13
created

testGetStrictTypesUnknownExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace FileEye\MimeMap\test;
4
5
use FileEye\MimeMap\Extension;
6
use PHPUnit\Framework\TestCase;
7
8
class ExtensionTest extends TestCase
9
{
10
    public function testGetDefaultType()
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
    /**
19
     * @expectedException \FileEye\MimeMap\MappingException
20
     */
21
    public function testGetStrictDefaultTypeUnknownExtension()
22
    {
23
        $this->assertSame('application/octet-stream', (new Extension('ohmygodthatisnoextension'))->getDefaultType());
24
    }
25
26
    public function testGetNoStrictDefaultTypeUnknownExtension()
27
    {
28
        $this->assertSame('application/octet-stream', (new Extension('ohmygodthatisnoextension'))->getDefaultType(false));
29
    }
30
31
    public function testGetTypes()
32
    {
33
        $this->assertSame(['text/vnd.dvb.subtitle', 'image/vnd.dvb.subtitle'], (new Extension('sub'))->getTypes());
34
        $this->assertSame(['text/vnd.dvb.subtitle', 'image/vnd.dvb.subtitle'], (new Extension('sUb'))->getTypes());
35
    }
36
37
    /**
38
     * @expectedException \FileEye\MimeMap\MappingException
39
     */
40
    public function testGetStrictTypesUnknownExtension()
41
    {
42
        $this->assertSame(['application/octet-stream'], (new Extension('ohmygodthatisnoextension'))->getTypes());
43
    }
44
45
    public function testGetNoStrictTypesUnknownExtension()
46
    {
47
        $this->assertSame(['application/octet-stream'], (new Extension('ohmygodthatisnoextension'))->getTypes(false));
48
    }
49
}
50