Passed
Pull Request — master (#416)
by Sergei
02:35
created

onfigTest.php$0   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 4
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
wmc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\TestEnvironments\WithoutIntl;
6
7
use Yiisoft\Translator\CategorySource;
8
use Yiisoft\Translator\MessageFormatterInterface;
9
use Yiisoft\Validator\Tests\BaseConfigTest;
10
11
final class ConfigTest extends BaseConfigTest
12
{
13
    public function testSimpleMessageFormatter(): void
14
    {
15
        $container = $this->createContainer();
16
17
        $customFormatter = new class () implements MessageFormatterInterface {
18
            public function format(string $message, array $parameters, string $locale): string
19
            {
20
                return 'test';
21
            }
22
        };
23
24
        /** @var CategorySource $translationCategorySource */
25
        $translationCategorySource = $container->get('[email protected]')[0];
26
        $message = '{n, selectordinal, one{#-one} two{#-two} few{#-few} other{#-other}}';
27
28
        // The default formatter argument is ignored in favor of formatter set in config.
29
        $this->assertSame(
30
            '1',
31
            $translationCategorySource->format($message, ['n' => 1], 'en', $customFormatter),
32
        );
33
    }
34
}
35