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

TypeParameterTest::testHasCommentNegative()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
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\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