4
4
5
5
use FileEye \MimeMap \Extension ;
6
6
use FileEye \MimeMap \MalformedTypeException ;
7
+ use FileEye \MimeMap \Map \DefaultMap ;
8
+ use FileEye \MimeMap \Map \EmptyMap ;
7
9
use FileEye \MimeMap \Map \MimeMapInterface ;
8
10
use FileEye \MimeMap \MapHandler ;
9
11
use FileEye \MimeMap \MappingException ;
@@ -21,6 +23,15 @@ public function setUp(): void
21
23
$ this ->map = MapHandler::map ();
22
24
}
23
25
26
+ public function testSetDefaultMapClass (): void
27
+ {
28
+ MapHandler::setDefaultMapClass (EmptyMap::class);
29
+ $ this ->assertInstanceOf (EmptyMap::class, MapHandler::map ());
30
+ MapHandler::setDefaultMapClass (DefaultMap::class);
31
+ // @phpstan-ignore method.impossibleType
32
+ $ this ->assertInstanceOf (DefaultMap::class, MapHandler::map ());
33
+ }
34
+
24
35
public function testMap (): void
25
36
{
26
37
$ this ->assertStringContainsString ('DefaultMap.php ' , $ this ->map ->getFileName ());
@@ -37,8 +48,10 @@ public function testAdd(): void
37
48
{
38
49
// Adding a new type with a new extension.
39
50
$ this ->map ->addTypeExtensionMapping ('bingo/bongo ' , 'bngbng ' );
51
+ $ this ->map ->addTypeDescription ('bingo/bongo ' , 'Bingo, Bongo! ' );
40
52
$ this ->assertSame (['bngbng ' ], (new Type ('bingo/bongo ' ))->getExtensions ());
41
53
$ this ->assertSame ('bngbng ' , (new Type ('bingo/bongo ' ))->getDefaultExtension ());
54
+ $ this ->assertSame ('Bingo, Bongo! ' , (new Type ('bingo/bongo ' ))->getDescription ());
42
55
$ this ->assertSame (['bingo/bongo ' ], (new Extension ('bngbng ' ))->getTypes ());
43
56
$ this ->assertSame ('bingo/bongo ' , (new Extension ('bngbng ' ))->getDefaultType ());
44
57
@@ -190,6 +203,14 @@ public function testSetExtensionDefaultType(): void
190
203
$ this ->assertSame (['image/vnd.dvb.subtitle ' , 'text/vnd.dvb.subtitle ' , 'text/x-microdvd ' , 'text/x-mpsub ' , 'text/x-subviewer ' ], (new Extension ('SUB ' ))->getTypes ());
191
204
}
192
205
206
+ public function testAddAliasToType (): void
207
+ {
208
+ $ this ->assertSame (['image/psd ' , 'image/x-psd ' , 'image/photoshop ' , 'image/x-photoshop ' , 'application/photoshop ' , 'application/x-photoshop ' ,], (new Type ('image/vnd.adobe.photoshop ' ))->getAliases ());
209
+ $ this ->map ->addTypeAlias ('image/vnd.adobe.photoshop ' , 'application/x-foo-bar ' );
210
+ $ this ->assertSame (['image/psd ' , 'image/x-psd ' , 'image/photoshop ' , 'image/x-photoshop ' , 'application/photoshop ' , 'application/x-photoshop ' , 'application/x-foo-bar ' ,], (new Type ('image/vnd.adobe.photoshop ' ))->getAliases ());
211
+ $ this ->assertContains ('application/x-foo-bar ' , $ this ->map ->listAliases ());
212
+ }
213
+
193
214
public function testReAddAliasToType (): void
194
215
{
195
216
$ this ->assertSame (['image/psd ' , 'image/x-psd ' , 'image/photoshop ' , 'image/x-photoshop ' , 'application/photoshop ' , 'application/x-photoshop ' ,], (new Type ('image/vnd.adobe.photoshop ' ))->getAliases ());
0 commit comments