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
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
namespace UniversalLanguageSelector\Tests;
use FontRepoCompiler;
/**
* @covers \FontRepoCompiler
*
* @license GPL-2.0-or-later
* @author Thiemo Kreuz
*/
class FontRepoCompilerTest extends \PHPUnit\Framework\TestCase {
public function testGetLanguages() {
$instance = new FontRepoCompiler( '', '' );
$result = $instance->getLanguages( [ 'languages' => 'de, en' ] );
$this->assertSame( [ 'de', 'en' ], $result );
}
public function testAppendLanguages() {
$instance = new FontRepoCompiler( '', '' );
$languages = [ 'de' => [] ];
$fontLanguages = [ 'de', 'en', 'fr*' ];
$instance->appendLanguages( $languages, $fontLanguages, 'dummyFontName' );
$this->assertSame( [
'de' => [ 'dummyFontName' ],
'en' => [ 'system', 'dummyFontName' ],
'fr' => [ 'dummyFontName' ],
], $languages );
}
public function testGetAllBasicFontInfo() {
$instance = new FontRepoCompiler( '', '' );
$givenInfo = [
'fontweight' => 'dummyFontWeight',
'fontstyle' => 'dummyFontStyle',
'woff' => 'Alef-Regular.woff',
'bold' => 'dummyBold',
'bolditalic' => 'dummyBoldItalic',
'italic' => 'dummyItalic',
];
$result = $instance->getFontInfo( $givenInfo, __DIR__ . '/../../data/fontrepo/fonts/Alef' );
$this->assertSame( [
'fontweight' => 'dummyFontWeight',
'fontstyle' => 'dummyFontStyle',
'woff' => 'Alef/Alef-Regular.woff?2b430',
'variants' => [
'bold' => 'dummyBold',
'bolditalic' => 'dummyBoldItalic',
'italic' => 'dummyItalic',
],
], $result );
}
public function testScanForWoffFiles() {
$instance = new FontRepoCompiler( '', '' );
$result = $instance->getFontInfo( [], __DIR__ . '/../../data/fontrepo/fonts/Alef' );
$this->assertSame( [
'woff' => 'Alef/Alef-Regular.woff?2b430',
'woff2' => 'Alef/Alef-Regular.woff2?a2499',
], $result );
}
public function testGetRepository() {
$path = __DIR__ . '/../../data/fontrepo/fonts';
$instance = new FontRepoCompiler( $path, 'dummyPath' );
$result = $instance->getRepository();
$this->assertSame( 'dummyPath', $result['base'], 'base' );
$this->assertContainsOnly( 'array', $result['languages'], 'languages' );
$this->assertContainsOnly( 'array', $result['fonts'], 'fonts' );
}
}
|