forked from Skillshare/formatphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigTest.php
More file actions
42 lines (34 loc) · 1.52 KB
/
ConfigTest.php
File metadata and controls
42 lines (34 loc) · 1.52 KB
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
<?php
declare(strict_types=1);
namespace FormatPHP\Test;
use FormatPHP\Config;
use FormatPHP\Extractor\IdInterpolator;
use FormatPHP\Intl\Locale;
use Locale as PhpLocale;
class ConfigTest extends TestCase
{
public function testInstanceConstruction(): void
{
$locale = new Locale('en-US');
$defaultLocale = new Locale('en');
$defaultRichTextElements = [
'em' => fn (string $text): string => '<em class="bar">' . $text . '</em>',
'strong' => fn (string $text): string => '<strong class="foo">' . $text . '</strong>',
];
$idInterpolatorPattern = '[md5:contenthash:base64:16]';
$config = new Config($locale, $defaultLocale, $defaultRichTextElements, $idInterpolatorPattern);
$this->assertSame($locale, $config->getLocale());
$this->assertSame($defaultLocale, $config->getDefaultLocale());
$this->assertSame($defaultRichTextElements, $config->getDefaultRichTextElements());
$this->assertSame($idInterpolatorPattern, $config->getIdInterpolatorPattern());
}
public function testConfigDefaults(): void
{
$systemLocale = new Locale(PhpLocale::getDefault());
$config = new Config();
$this->assertSame($systemLocale->toString(), $config->getLocale()->toString());
$this->assertNull($config->getDefaultLocale());
$this->assertSame([], $config->getDefaultRichTextElements());
$this->assertSame(IdInterpolator::DEFAULT_ID_INTERPOLATION_PATTERN, $config->getIdInterpolatorPattern());
}
}