-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-47439: [Github] i18n:collect-phrases -m can't find many impor…
…tant magento phrases #2630 - Added tests.
- Loading branch information
Hayder Sharhan
committed
Jan 26, 2016
1 parent
4e5466e
commit aa044b4
Showing
4 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/JsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Setup\Module\I18n\Parser\Adapter; | ||
|
||
/** | ||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Js | ||
* | ||
*/ | ||
class JsTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Js | ||
*/ | ||
protected $jsPhraseCollector; | ||
|
||
protected function setUp() | ||
{ | ||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
$this->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()); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/XmlTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Setup\Module\I18n\Parser\Adapter; | ||
|
||
/** | ||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Xml | ||
* | ||
*/ | ||
class XmlTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Xml | ||
*/ | ||
protected $xmlPhraseCollector; | ||
|
||
protected function setUp() | ||
{ | ||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
$this->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()); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...integration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/jsPhrasesForTest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$t("text double quote"); | ||
$t('text single quote'); | ||
$t('text "some'); |
17 changes: 17 additions & 0 deletions
17
...tegration/testsuite/Magento/Setup/Module/I18n/Parser/Adapter/_files/xmlPhrasesForTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config> | ||
<node name="Name only" translate="name"/> | ||
<node name="Name and title space delimiter" title="title1" translate="name title"/> | ||
<node name="Name and title comma delimiter" title="title2" translate="name, title"/> | ||
<node translate="name"> | ||
<name>Name only in sub node</name> | ||
<notName>This shouldn't be picked up</notName> | ||
</node> | ||
<node translate="true">Text outside of attribute</node> | ||
</config> |