forked from josantonius/php-mime-type
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMimeTypeTest.php
68 lines (51 loc) · 1.84 KB
/
MimeTypeTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/*
* This file is part of https://github.com/josantonius/php-mime-type repository.
*
* (c) Josantonius <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
*/
namespace Josantonius\MimeType\Tests;
use PHPUnit\Framework\TestCase;
use Josantonius\MimeType\MimeType;
use Josantonius\MimeType\MimeTypeCollection;
class MimeTypeTest extends TestCase
{
protected MimeType $mimeType;
protected MimeTypeCollection $collection;
public function setUp(): void
{
parent::setUp();
$this->mimeType = new MimeType();
$this->collection = new MimeTypeCollection();
}
public function test_should_get_all_mime_types(): void
{
$this->assertNotEmpty($this->mimeType->all());
$this->assertNotEmpty($this->collection->all());
}
public function test_should_get_mime_type_from_extension(): void
{
$this->assertSame('text/html', $this->mimeType->getMime('.html'));
$this->assertSame('text/html', $this->collection->getMime('.html'));
}
public function test_should_return_null_with_an_unknown_extension(): void
{
$this->assertNull($this->mimeType->getMime('.foo'));
$this->assertNull($this->collection->getMime('.foo'));
}
public function test_should_get_extension_from_mime_type(): void
{
$this->assertSame('.html', $this->mimeType->getExtension('text/html'));
$this->assertSame('.html', $this->collection->getExtension('text/html'));
}
public function test_should_return_null_with_an_unknown_mime_type(): void
{
$this->assertNull($this->mimeType->getExtension('bar'));
$this->assertNull($this->collection->getExtension('bar'));
}
}