Passed
Pull Request — master (#2)
by mon
03:19
created

TypeParameterTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

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