From aa044b4b33edb914fee4ed3ba25045d417073bf9 Mon Sep 17 00:00:00 2001 From: Hayder Sharhan Date: Tue, 26 Jan 2016 14:42:57 -0600 Subject: [PATCH] MAGETWO-47439: [Github] i18n:collect-phrases -m can't find many important magento phrases #2630 - Added tests. --- .../Module/I18n/Parser/Adapter/JsTest.php | 53 ++++++++++++++ .../Module/I18n/Parser/Adapter/XmlTest.php | 71 +++++++++++++++++++ .../Parser/Adapter/_files/jsPhrasesForTest.js | 3 + .../Adapter/_files/xmlPhrasesForTest.xml | 17 +++++ 4 files changed, 144 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/JsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/XmlTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/jsPhrasesForTest.js create mode 100644 dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/xmlPhrasesForTest.xml diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/JsTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/JsTest.php new file mode 100644 index 0000000000000..0b06f64a24d5f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/JsTest.php @@ -0,0 +1,53 @@ +jsPhraseCollector = $objectManager->create( + 'Magento\Setup\Module\I18n\Parser\Adapter\Js' + ); + } + + public function testParse() + { + $file = __DIR__ . '/_files/jsPhrasesForTest.js'; + $this->jsPhraseCollector->parse($file); + $expectation = [ + [ + 'phrase' => 'text double quote', + 'file' => $file, + 'line' => 1, + 'quote' => '"' + ], + [ + 'phrase' => 'text single quote', + 'file' => $file, + 'line' => 2, + 'quote' => '\'' + ], + [ + 'phrase' => 'text "some', + 'file' => $file, + 'line' => 3, + 'quote' => '\'' + ] + ]; + $this->assertEquals($expectation, $this->jsPhraseCollector->getPhrases()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/XmlTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/XmlTest.php new file mode 100644 index 0000000000000..64cc04347b950 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/XmlTest.php @@ -0,0 +1,71 @@ +xmlPhraseCollector = $objectManager->create( + 'Magento\Setup\Module\I18n\Parser\Adapter\Xml' + ); + } + + public function testParse() + { + $file = __DIR__ . '/_files/xmlPhrasesForTest.xml'; + $this->xmlPhraseCollector->parse($file); + $expectation = [ + [ + 'phrase' => 'Name only', + 'file' => $file, + 'line' => '', + 'quote' => '' + ], + [ + 'phrase' => 'Name and title space delimiter', + 'file' => $file, + 'line' => '', + 'quote' => '' + ], + [ + 'phrase' => 'title1', + 'file' => $file, + 'line' => '', + 'quote' => '' + ], + [ + 'phrase' => 'title2', + 'file' => $file, + 'line' => '', + 'quote' => '' + ], + [ + 'phrase' => 'Name only in sub node', + 'file' => $file, + 'line' => '', + 'quote' => '' + ], + [ + 'phrase' => 'Text outside of attribute', + 'file' => $file, + 'line' => '', + 'quote' => '' + ] + ]; + $this->assertEquals($expectation, $this->xmlPhraseCollector->getPhrases()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/jsPhrasesForTest.js b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/jsPhrasesForTest.js new file mode 100644 index 0000000000000..1e1afeeec8752 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/jsPhrasesForTest.js @@ -0,0 +1,3 @@ +$t("text double quote"); +$t('text single quote'); +$t('text "some'); diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/xmlPhrasesForTest.xml b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/xmlPhrasesForTest.xml new file mode 100644 index 0000000000000..d86ad72265b09 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/xmlPhrasesForTest.xml @@ -0,0 +1,17 @@ + + + + + + + + Name only in sub node + This shouldn't be picked up + + Text outside of attribute +