]> projects.mako.cc - scuttle/blob - includes/php-gettext/tests/ParsingTest.php
updated readme with information on a series of bugs I know exist
[scuttle] / includes / php-gettext / tests / ParsingTest.php
1 <?php
2 require_once('PHPUnit/Framework.php');
3 //require_once('gettext.php');
4
5 class ParsingTest extends PHPUnit_Framework_TestCase
6 {
7   public function test_extract_plural_forms_header_from_po_header()
8   {
9     $parser = new gettext_reader(NULL);
10     // It defaults to a "Western-style" plural header.
11     $this->assertEquals(
12       'nplurals=2; plural=n == 1 ? 0 : 1;',
13       $parser->extract_plural_forms_header_from_po_header(""));
14
15     // Extracting it from the middle of the header works.
16     $this->assertEquals(
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"
22       ));
23
24     // It's also case-insensitive.
25     $this->assertEquals(
26       'nplurals=1; plural=0;',
27       $parser->extract_plural_forms_header_from_po_header(
28         "PLURAL-forms: nplurals=1; plural=0;\n"
29       ));
30
31     // It falls back to default if it's not on a separate line.
32     $this->assertEquals(
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"
38       ));
39
40   }
41
42 }
43 ?>

Benjamin Mako Hill || Want to submit a patch?