2 require_once('PHPUnit/Framework.php');
3 //require_once('gettext.php');
5 class ParsingTest extends PHPUnit_Framework_TestCase
7 public function test_extract_plural_forms_header_from_po_header()
9 $parser = new gettext_reader(NULL);
10 // It defaults to a "Western-style" plural header.
12 'nplurals=2; plural=n == 1 ? 0 : 1;',
13 $parser->extract_plural_forms_header_from_po_header(""));
15 // Extracting it from the middle of the header works.
17 'nplurals=1; plural=0;',
18 $parser->extract_plural_forms_header_from_po_header(
19 "Content-type: text/html; charset=UTF-8\n"
20 ."Plural-Forms: nplurals=1; plural=0;\n"
21 ."Last-Translator: nobody\n"
24 // It's also case-insensitive.
26 'nplurals=1; plural=0;',
27 $parser->extract_plural_forms_header_from_po_header(
28 "PLURAL-forms: nplurals=1; plural=0;\n"
31 // It falls back to default if it's not on a separate line.
33 'nplurals=2; plural=n == 1 ? 0 : 1;',
34 $parser->extract_plural_forms_header_from_po_header(
35 "Content-type: text/html; charset=UTF-8" // note the missing \n here
36 ."Plural-Forms: nplurals=1; plural=0;\n"
37 ."Last-Translator: nobody\n"