Completed
Push — master ( 6a08aa...2252e8 )
by William
03:47
created

FunctionsTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\MoTranslator\Tests;
6
7
use PhpMyAdmin\MoTranslator\Loader;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Test for functions.
12
 */
13
class FunctionsTest extends TestCase
14
{
15
    public function setUp(): void
16
    {
17
        Loader::loadFunctions();
18
19
        _setlocale(0, 'cs');
20
        _textdomain('phpmyadmin');
21
        _bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/');
22
        _bind_textdomain_codeset('phpmyadmin', 'UTF-8');
23
    }
24
25
    public function testGettext(): void
26
    {
27
        $this->assertEquals(
28
            'Typ',
29
            _gettext('Type')
30
        );
31
32
        $this->assertEquals(
33
            'Typ',
34
            __('Type')
35
        );
36
37
        $this->assertEquals(
38
            '%d sekundy',
39
            _ngettext(
40
                '%d second',
41
                '%d seconds',
42
                2
43
            )
44
        );
45
46
        $this->assertEquals(
47
            '%d seconds',
48
            _npgettext(
49
                'context',
50
                '%d second',
51
                '%d seconds',
52
                2
53
            )
54
        );
55
56
        $this->assertEquals(
57
            'Tabulka',
58
            _pgettext(
59
                'Display format',
60
                'Table'
61
            )
62
        );
63
    }
64
65
    public function testDomain(): void
66
    {
67
        $this->assertEquals(
68
            'Typ',
69
            _dgettext('phpmyadmin', 'Type')
70
        );
71
72
        $this->assertEquals(
73
            '%d sekundy',
74
            _dngettext(
75
                'phpmyadmin',
76
                '%d second',
77
                '%d seconds',
78
                2
79
            )
80
        );
81
82
        $this->assertEquals(
83
            '%d seconds',
84
            _dnpgettext(
85
                'phpmyadmin',
86
                'context',
87
                '%d second',
88
                '%d seconds',
89
                2
90
            )
91
        );
92
93
        $this->assertEquals(
94
            'Tabulka',
95
            _dpgettext(
96
                'phpmyadmin',
97
                'Display format',
98
                'Table'
99
            )
100
        );
101
    }
102
}
103