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

PluralTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
dl 0
loc 35
c 1
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNpgettext() 0 10 1
A providerTestNpgettext() 0 10 1
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