Skip to content

Commit

Permalink
MAGETWO-47439: [Github] i18n:collect-phrases -m can't find many impor…
Browse files Browse the repository at this point in the history
…tant magento phrases #2630

- Added tests.
  • Loading branch information
Hayder Sharhan committed Jan 26, 2016
1 parent 4e5466e commit aa044b4
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
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());
}
}
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());
}
}
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');
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>

0 comments on commit aa044b4

Please sign in to comment.