2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for gettext parsing.
6 * @package phpMyAdmin-test
8 //require_once('gettext.php');
10 class ParsingTest
extends PHPUnit_Framework_TestCase
12 public function test_extract_plural_forms_header_from_po_header()
14 $parser = new gettext_reader(NULL);
15 // It defaults to a "Western-style" plural header.
17 'nplurals=2; plural=n == 1 ? 0 : 1;',
18 $parser->extract_plural_forms_header_from_po_header(""));
20 // Extracting it from the middle of the header works.
22 'nplurals=1; plural=0;',
23 $parser->extract_plural_forms_header_from_po_header(
24 "Content-type: text/html; charset=UTF-8\n"
25 ."Plural-Forms: nplurals=1; plural=0;\n"
26 ."Last-Translator: nobody\n"
29 // It's also case-insensitive.
31 'nplurals=1; plural=0;',
32 $parser->extract_plural_forms_header_from_po_header(
33 "PLURAL-forms: nplurals=1; plural=0;\n"
36 // It falls back to default if it's not on a separate line.
38 'nplurals=2; plural=n == 1 ? 0 : 1;',
39 $parser->extract_plural_forms_header_from_po_header(
40 "Content-type: text/html; charset=UTF-8" // note the missing \n here
41 ."Plural-Forms: nplurals=1; plural=0;\n"
42 ."Last-Translator: nobody\n"
47 * @dataProvider data_provider_test_npgettext
49 public function test_npgettext($number, $expected) {
50 $parser = new gettext_reader(NULL);
51 $result = $parser->npgettext("context",
52 "%d pig went to the market\n",
53 "%d pigs went to the market\n",
55 $this->assertSame($expected, $result);
57 public static function data_provider_test_npgettext() {
59 array(1, "%d pig went to the market\n"),
60 array(2, "%d pigs went to the market\n"),