|
1
|
|
|
<?php |
|
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() |
|
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() |
|
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
|
|
|
|