[icinga-checkins] icinga.org: icingaweb2/feature/po-file-parser-13011: CatalogParserTest: Add unit tests for CatalogParser

git at icinga.org git at icinga.org
Fri Nov 4 14:17:34 CET 2016


Module: icingaweb2
Branch: feature/po-file-parser-13011
Commit: 89fc302d752346564d68d22100e0dee0d1c49ad4
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=89fc302d752346564d68d22100e0dee0d1c49ad4

Author: Jennifer Mourek <jennifer.mourek at netways.de>
Date:   Fri Nov  4 14:16:56 2016 +0100

CatalogParserTest: Add unit tests for CatalogParser

---

 .../Translation/Catalog/CatalogParserTest.php      |  162 +++++++++++++++++++-
 .../test/php/library/Translation/Catalog/test.po   |   51 +++---
 2 files changed, 191 insertions(+), 22 deletions(-)

diff --git a/modules/translation/test/php/library/Translation/Catalog/CatalogParserTest.php b/modules/translation/test/php/library/Translation/Catalog/CatalogParserTest.php
index 0cb36af..2cac43b 100644
--- a/modules/translation/test/php/library/Translation/Catalog/CatalogParserTest.php
+++ b/modules/translation/test/php/library/Translation/Catalog/CatalogParserTest.php
@@ -10,11 +10,171 @@ use Icinga\Test\BaseTestCase;
 
 class CatalogParserTest extends BaseTestCase
 {
+    public function testWhetherMsgctxtIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'context of the message',
+            $parserResult[1]['msgctxt'],
+            'CatalogParser::parsePath does not parse msgctxt correctly'
+        );
+    }
+
+    public function testWhetherFuzzyMsgctxtIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'fuzzy context of the message',
+            $parserResult[1]['fuzzy_msgctxt'],
+            'CatalogParser::parsePath does not parse fuzzy_msgctxt correctly'
+        );
+    }
+
+    public function testWhetherMsgidIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'first line second line',
+            $parserResult[1]['msgid'],
+            'CatalogParser::parsePath does not parse msgid correctly'
+        );
+    }
+
+    public function testWhetherObsoleteMsgidIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'obsolete_id_line1 obsolete_id_line2',
+            $parserResult[3]['obsolete_msgid'],
+            'CatalogParser::parsePath does not parse obsolete_msgid correctly'
+        );
+    }
+
+    public function testWhetherFuzzyMsgidIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'fuzzy id of the message',
+            $parserResult[1]['fuzzy_msgid'],
+            'CatalogParser::parsePath does not parse fuzzy_msgid correctly'
+        );
+    }
+
+    public function testWhetherMsgstrIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'Erste Zeile Zweite Zeile',
+            $parserResult[1]['msgstr'],
+            'CatalogParser::parsePath does not parse msgstr correctly'
+        );
+    }
+
+    public function testWhetherObsoleteMsgstrIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'obsolete_string_line1 obsolete_string_line2',
+            $parserResult[3]['obsolete_msgstr'],
+            'CatalogParser::parsePath does not parse obsolete_msgstr correctly'
+        );
+    }
+
+    public function testWhetherMsgidPluralIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'id_plural',
+            $parserResult[2]['msgid_plural'],
+            'CatalogParser::parsePath does not parse msgid_plural correctly'
+        );
+    }
+
+    public function testWhetherObsoleteMsgidPluralIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'id_plural_line1 id_plural_line2',
+            $parserResult[4]['obsolete_msgid_plural'],
+            'CatalogParser::parsePath does not parse obsolete_msgid_plural correctly'
+        );
+    }
+
+    public function testWhetherFuzzyMsgidPluralIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'fuzzy_id_plural',
+            $parserResult[2]['fuzzy_msgid_plural'],
+            'CatalogParser::parsePath does not parse fuzzy_msgid_plural correctly'
+        );
+    }
+
+    public function testWhetherMsgstrPluralIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'string0',
+            $parserResult[2]['msgstr_plural[0]'],
+            'CatalogParser::parsePath does not parse msgstr_plural[0] correctly'
+        );
+    }
+
+    public function testWhetherObsoleteMsgstrPluralIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'string_line1 string_line2',
+            $parserResult[4]['obsolete_msgstr_plural[0]'],
+            'CatalogParser::parsePath does not parse obsolete_msgstr_plural[0] correctly'
+        );
+    }
+
+    public function testWhetherTranslatorCommentIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'this is a',
+            $parserResult[1]['translator_comments'][0],
+            'CatalogParser::parsePath does not parse translator_comment correctly'
+        );
+    }
+
+    public function testWhetherExtractedCommentIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'this is an',
+            $parserResult[1]['extracted_comments'][0],
+            'CatalogParser::parsePath does not parse extracted_comment correctly'
+        );
+    }
+
+    public function testWhetherPathIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            '/second/path:123',
+            $parserResult[1]['paths'][1],
+            'CatalogParser::parsePath does not parse paths correctly'
+        );
+    }
+
+    public function testWhetherFlagIsParsedCorrectly() {
+        $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
+
+        $this->assertEquals(
+            'format2',
+            $parserResult[1]['flags'][1],
+            'CatalogParser::parsePath does not parse flags correctly'
+        );
+    }
+
     public function testWhetherParsePathReturnsTheFirstLineOfAGivenFileCorrectly()
     {
         $parserResult = CatalogParser::parsePath('/vagrant/modules/translation/test/php/library/Translation/Catalog/test.po');
 
-        var_dump($parserResult);
+        #var_dump($parserResult);
 
         /*$this->assertEquals(
             'test2',
diff --git a/modules/translation/test/php/library/Translation/Catalog/test.po b/modules/translation/test/php/library/Translation/Catalog/test.po
index b927b43..e5954b7 100644
--- a/modules/translation/test/php/library/Translation/Catalog/test.po
+++ b/modules/translation/test/php/library/Translation/Catalog/test.po
@@ -6,27 +6,36 @@ msgstr ""
 "PO-Revision-Date: 2016-09-27 11:15+0200\n"
 "Last-Translator: Eric Lippmann <eric.lippmann at netways.de>\n"
 
-# this is a translator comment
-#. this is a extracted comment
-#: /this/is/a/path /second/path
-#: /third/path
-#, format1, fuzzy(format2)
+# this is a
+# translator comment
+#. this is an
+#. extracted comment
+#: /this/is/a/path:142 /second/path:123
+#: /third/path:1243
+#, format1, format2
+#| msgctxt "fuzzy context of the message"
+#| msgid "fuzzy id of the message"
 msgctxt "context of the message"
-msgid ""
-"\"%s\" is not in the list of allowed values. Did you mean one of the "
-"following?: %s"
-msgstr ""
-"“%s” ist nicht in der Liste der erlaubten Werte. Meinten Sie vielleicht "
-"einen der Folgenden?: %s"
+msgid "first line "
+"second line"
+msgstr "Erste Zeile "
+"Zweite Zeile"
+
+#: /vagrant/modules/monitoring/application/views/scripts/tactical/components/hostservicechecks.phtml:55
+#| msgid_plural "fuzzy_id_plural"
+msgid "id"
+msgid_plural "id_plural"
+msgstr[0] "string0"
+msgstr[1] "string1"
 
-#: /vagrant/library/Icinga/Date/DateFormatter.php:171
-#, php-format
-msgid "%s ago"
-msgstr "vor %s"
+#~ msgid "obsolete_id_line1 "
+#~ "obsolete_id_line2"
+#~ msgstr "obsolete_string_line1 "
+#~ "obsolete_string_line2"
 
-#~ msgid ""
-#~ "You need to install the php extension \"pgsql\" and the Zend_Pdo_Pgsql "
-#~ "classes to use PostgreSQL database resources."
-#~ msgstr ""
-#~ "Um PostgreSQL Datenbank-Ressourcen nutzen zu können müssen die PHP-"
-#~ "Erweiterung \"pqsql\" sowie die Zend_Pdo_Pgsql Klassen installiert sein."
+#~ msgid "id"
+#~ msgid_plural "id_plural_line1 "
+#~ "id_plural_line2"
+#~ msgstr[0] "string_line1 "
+#~ "string_line2"
+#~ msgstr[1] "string1"



More information about the icinga-checkins mailing list