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 +