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

PluralTest::providerTestNpgettext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 10
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\Translator;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Test for gettext parsing.
12
 */
13
class PluralTest extends TestCase
14
{
15
    /**
16
     * Test for npgettext.
17
     *
18
     * @param int    $number   Number
19
     * @param string $expected Expected output
20
     *
21
     * @dataProvider providerTestNpgettext
22
     */
23
    public function testNpgettext(int $number, string $expected): void
24
    {
25
        $parser = new Translator('');
26
        $result = $parser->npgettext(
27
            'context',
28
            "%d pig went to the market\n",
29
            "%d pigs went to the market\n",
30
            $number
31
        );
32
        $this->assertSame($expected, $result);
33
    }
34
35
    /**
36
     * Data provider for test_npgettext.
37
     */
38
    public static function providerTestNpgettext(): array
39
    {
40
        return [
41
            [
42
                1,
43
                "%d pig went to the market\n",
44
            ],
45
            [
46
                2,
47
                "%d pigs went to the market\n",
48
            ],
49
        ];
50
    }
51
}
52