TypeParameterTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasCommentNegative() 0 10 1
A testHasComment() 0 12 1
1
<?php declare(strict_types=1);
2
3
namespace FileEye\MimeMap\Test;
4
5
use FileEye\MimeMap\Type;
6
use FileEye\MimeMap\TypeParameter;
7
8
class TypeParameterTest extends MimeMapTestBase
9
{
10
    public function testHasComment(): void
11
    {
12
        $mt = new Type('image/png; a="parameter" (with a comment)');
13
        $this->assertSame('a', $mt->getParameter('a')->getName());
14
        $this->assertSame('parameter', $mt->getParameter('a')->getValue());
15
        $this->assertTrue($mt->getParameter('a')->hasComment());
16
        $this->assertSame('with a comment', $mt->getParameter('a')->getComment());
17
        $mt = new Type('image/png;param=foo(with a comment)');
18
        $this->assertSame('param', $mt->getParameter('param')->getName());
19
        $this->assertSame('foo', $mt->getParameter('param')->getValue());
20
        $this->assertTrue($mt->getParameter('param')->hasComment());
21
        $this->assertSame('with a comment', $mt->getParameter('param')->getComment());
22
    }
23
24
    public function testHasCommentNegative(): void
25
    {
26
        $mt = new Type('image/png; a="parameter"');
27
        $this->assertSame('a', $mt->getParameter('a')->getName());
28
        $this->assertSame('parameter', $mt->getParameter('a')->getValue());
29
        $this->assertFalse($mt->getParameter('a')->hasComment());
30
        $mt = new Type('image/png;foo=bar');
31
        $this->assertSame('foo', $mt->getParameter('foo')->getName());
32
        $this->assertSame('bar', $mt->getParameter('foo')->getValue());
33
        $this->assertFalse($mt->getParameter('foo')->hasComment());
34
    }
35
}
36