1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
4
|
|
|
* |
5
|
|
|
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics) |
6
|
|
|
* |
7
|
|
|
* This program is free software; you can redistribute it and/or |
8
|
|
|
* modify it under the terms of the GNU General Public License |
9
|
|
|
* as published by the Free Software Foundation; either version 2 |
10
|
|
|
* of the License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with this program; if not, write to the Free Software |
19
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace App\Tests\Services; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
use App\Services\FAIconGenerator; |
26
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
27
|
|
|
|
28
|
|
|
class FAIconGeneratorTest extends WebTestCase |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var AmountFormatter |
32
|
|
|
*/ |
33
|
|
|
protected $service; |
34
|
|
|
|
35
|
|
|
public function setUp() |
36
|
|
|
{ |
37
|
|
|
parent::setUp(); // TODO: Change the autogenerated stub |
38
|
|
|
|
39
|
|
|
//Get an service instance. |
40
|
|
|
self::bootKernel(); |
41
|
|
|
$this->service = self::$container->get(FAIconGenerator::class); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function fileExtensionDataProvider() : array |
45
|
|
|
{ |
46
|
|
|
return [ |
47
|
|
|
['pdf', 'fa-file-pdf'], |
48
|
|
|
['jpeg', 'fa-file-image'], |
49
|
|
|
['txt', 'fa-file-alt'], |
50
|
|
|
['doc', 'fa-file-word'], |
51
|
|
|
['zip', 'fa-file-archive'], |
52
|
|
|
['php', 'fa-file-code'], |
53
|
|
|
['tmp', 'fa-file'], |
54
|
|
|
['fgd', 'fa-file'], |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @dataProvider fileExtensionDataProvider |
60
|
|
|
*/ |
61
|
|
|
public function testFileExtensionToFAType(string $ext, string $expected) |
62
|
|
|
{ |
63
|
|
|
$this->assertEquals($expected, $this->service->fileExtensionToFAType($ext)); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testGenerateIconHTML() |
67
|
|
|
{ |
68
|
|
|
$this->assertEquals('<i class="fas fa-file "></i>', $this->service->generateIconHTML('fa-file')); |
69
|
|
|
$this->assertEquals('<i class="far fa-file "></i>', $this->service->generateIconHTML('fa-file', 'far')); |
70
|
|
|
$this->assertEquals('<i class="far fa-file fa-2x"></i>', $this->service->generateIconHTML('fa-file', 'far', 'fa-2x')); |
71
|
|
|
} |
72
|
|
|
} |