ltsecurityinc安防产品在线商城代码
This commit is contained in:
+116
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Dictionary;
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
use Magento\Setup\Module\I18n\Dictionary\Generator;
|
||||
use Magento\Setup\Module\I18n\ServiceLocator;
|
||||
|
||||
class GeneratorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $testDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $expectedDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $outputFileName;
|
||||
|
||||
/**
|
||||
* @var \Magento\Setup\Module\I18n\Dictionary\Generator
|
||||
*/
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $backupRegistrar;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$this->backupRegistrar = $paths->getValue();
|
||||
$paths->setValue(['module' => [], 'theme' => []]);
|
||||
$paths->setAccessible(false);
|
||||
|
||||
$this->testDir = realpath(__DIR__ . '/_files');
|
||||
$this->expectedDir = $this->testDir . '/expected';
|
||||
$this->source = $this->testDir . '/source';
|
||||
$this->outputFileName = $this->testDir . '/translate.csv';
|
||||
|
||||
// Register the test modules
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_FirstModule',
|
||||
$this->source . '/app/code/Magento/FirstModule'
|
||||
);
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_SecondModule',
|
||||
$this->source . '/app/code/Magento/SecondModule'
|
||||
);
|
||||
|
||||
// Register the test theme
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::THEME,
|
||||
'adminhtml/default/backend',
|
||||
$this->source . '/app/design/adminhtml/default/backend'
|
||||
);
|
||||
|
||||
$this->generator = ServiceLocator::getDictionaryGenerator();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists($this->outputFileName)) {
|
||||
unlink($this->outputFileName);
|
||||
}
|
||||
$property = new \ReflectionProperty(\Magento\Setup\Module\I18n\ServiceLocator::class, '_dictionaryGenerator');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue(null);
|
||||
$property->setAccessible(false);
|
||||
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$paths->setValue($this->backupRegistrar);
|
||||
$paths->setAccessible(false);
|
||||
}
|
||||
|
||||
public function testGenerationWithoutContext()
|
||||
{
|
||||
$this->generator->generate($this->source, $this->outputFileName);
|
||||
|
||||
$this->assertFileEquals($this->expectedDir . '/without_context.csv', $this->outputFileName);
|
||||
}
|
||||
|
||||
public function testGenerationWithContext()
|
||||
{
|
||||
$this->generator->generate($this->source, $this->outputFileName, true);
|
||||
|
||||
$expected = explode(PHP_EOL, file_get_contents($this->expectedDir . '/with_context.csv'));
|
||||
$output = file_get_contents($this->outputFileName);
|
||||
foreach ($expected as $line) {
|
||||
if ($line) {
|
||||
$this->assertStringContainsString($line, $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
Helper,Helper,module,Magento_FirstModule
|
||||
Model,Model,module,Magento_FirstModule
|
||||
"Module template","Module template",module,Magento_FirstModule
|
||||
Model,Model,module,Magento_SecondModule
|
||||
"Theme template","Theme template",theme,adminhtml/default/backend
|
||||
"Module js","Module js",module,Magento_FirstModule
|
||||
"Lib js","Lib js",lib,lib/web/mage/file.js
|
||||
"Lib js","Lib js",lib,lib/web/varien/file.js
|
||||
"Module layout label","Module layout label",module,Magento_FirstModule
|
||||
"Module layout title","Module layout title",module,Magento_FirstModule
|
||||
"Theme layout label","Theme layout label",theme,adminhtml/default/backend
|
||||
"Theme layout title","Theme layout title",theme,adminhtml/default/backend
|
||||
|
+13
@@ -0,0 +1,13 @@
|
||||
Helper,Helper
|
||||
Model,Model
|
||||
"Module template","Module template"
|
||||
"Theme template","Theme template"
|
||||
"Model unused","Model unused"
|
||||
"Theme template unused","Theme template unused"
|
||||
"Module js","Module js"
|
||||
"Lib js","Lib js"
|
||||
"Lib js unused","Lib js unused"
|
||||
"Module layout label","Module layout label"
|
||||
"Module layout title","Module layout title"
|
||||
"Theme layout label","Theme layout label"
|
||||
"Theme layout title","Theme layout title"
|
||||
|
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Helper;
|
||||
|
||||
class Helper
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Helper');
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Model;
|
||||
|
||||
class Model
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Model');
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version='1.0' encoding="utf-8" ?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
|
||||
<layout>
|
||||
<referenceBlock translate="description, label">
|
||||
<description>Module layout description</description>
|
||||
<label>Module layout label</label>
|
||||
<title translate="true">Module layout title</title>
|
||||
</referenceBlock>
|
||||
</layout>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Module js');
|
||||
});
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php __('Module template');
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\SecondModule\Model;
|
||||
|
||||
class Model
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Model');
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version='1.0' encoding="utf-8" ?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
|
||||
<layout>
|
||||
<referenceBlock translate="description, label">
|
||||
<description>Theme layout description</description>
|
||||
<label>Theme layout label</label>
|
||||
<title translate="true">Theme layout title</title>
|
||||
</referenceBlock>
|
||||
</layout>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php __('Theme template');
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Lib js')
|
||||
});
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Lib js')
|
||||
});
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Model;
|
||||
|
||||
class Model
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Model unused');
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Lib js unused')
|
||||
});
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php __('Theme template unused');
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Pack;
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
use Magento\Setup\Module\I18n\ServiceLocator;
|
||||
|
||||
class GeneratorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_testDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_expectedDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_dictionaryPath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_packPath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_locale;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_expectedFiles;
|
||||
|
||||
/**
|
||||
* @var \Magento\Setup\Module\I18n\Pack\Generator
|
||||
*/
|
||||
protected $_generator;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $backupRegistrar;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->_testDir = realpath(__DIR__ . '/_files');
|
||||
$this->_expectedDir = $this->_testDir . '/expected';
|
||||
$this->_dictionaryPath = $this->_testDir . '/source.csv';
|
||||
$this->_packPath = $this->_testDir . '/pack';
|
||||
$this->_locale = 'de_DE';
|
||||
$this->_expectedFiles = [
|
||||
"/app/code/Magento/FirstModule/i18n/{$this->_locale}.csv",
|
||||
"/app/code/Magento/SecondModule/i18n/{$this->_locale}.csv",
|
||||
"/app/design/adminhtml/default/i18n/{$this->_locale}.csv",
|
||||
];
|
||||
|
||||
$this->_generator = ServiceLocator::getPackGenerator();
|
||||
|
||||
\Magento\Framework\System\Dirs::rm($this->_packPath);
|
||||
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$this->backupRegistrar = $paths->getValue();
|
||||
$paths->setAccessible(false);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
\Magento\Framework\System\Dirs::rm($this->_packPath);
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$paths->setValue($this->backupRegistrar);
|
||||
$paths->setAccessible(false);
|
||||
}
|
||||
|
||||
public function testGeneration()
|
||||
{
|
||||
$this->assertFileDoesNotExist($this->_packPath);
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_FirstModule',
|
||||
$this->_packPath . '/app/code/Magento/FirstModule'
|
||||
);
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_SecondModule',
|
||||
$this->_packPath. '/app/code/Magento/SecondModule'
|
||||
);
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::THEME,
|
||||
'adminhtml/default',
|
||||
$this->_packPath. '/app/design/adminhtml/default'
|
||||
);
|
||||
|
||||
$this->_generator->generate($this->_dictionaryPath, $this->_locale);
|
||||
|
||||
foreach ($this->_expectedFiles as $file) {
|
||||
$this->assertFileEquals($this->_expectedDir . $file, $this->_packPath . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Helper,Helper
|
||||
Model,Model
|
||||
"Module template","Module template"
|
||||
"Module js","Module js"
|
||||
"Module layout label","Module layout label"
|
||||
"Module layout title","Module layout title"
|
||||
|
+1
@@ -0,0 +1 @@
|
||||
Model,Model
|
||||
|
+3
@@ -0,0 +1,3 @@
|
||||
"Theme template","Theme template"
|
||||
"Theme layout label","Theme layout label"
|
||||
"Theme layout title","Theme layout title"
|
||||
|
+1
@@ -0,0 +1 @@
|
||||
"Lib js","Lib js"
|
||||
|
@@ -0,0 +1,10 @@
|
||||
Helper,Helper,module,Magento_FirstModule
|
||||
Model,Model,module,"Magento_FirstModule,Magento_SecondModule"
|
||||
"Module template","Module template",module,Magento_FirstModule
|
||||
"Theme template","Theme template",theme,adminhtml/default
|
||||
"Module js","Module js",module,Magento_FirstModule
|
||||
"Lib js","Lib js",lib,"lib/web/mage/file.js,lib/web/varien/file.js"
|
||||
"Module layout label","Module layout label",module,Magento_FirstModule
|
||||
"Module layout title","Module layout title",module,Magento_FirstModule
|
||||
"Theme layout label","Theme layout label",theme,adminhtml/default
|
||||
"Theme layout title","Theme layout title",theme,adminhtml/default
|
||||
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. 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(): void
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->jsPhraseCollector = $objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Js::class
|
||||
);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector
|
||||
*/
|
||||
class PhraseCollectorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var PhraseCollector
|
||||
*/
|
||||
protected $phraseCollector;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->phraseCollector = $this->objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::parse
|
||||
*/
|
||||
public function testParse()
|
||||
{
|
||||
$file = __DIR__.'/_files/objectsCode.php.txt';
|
||||
$this->phraseCollector->setIncludeObjects();
|
||||
$this->phraseCollector->parse($file);
|
||||
$expectation = [
|
||||
[
|
||||
'phrase' => '\'Testing\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 3
|
||||
],
|
||||
[
|
||||
'phrase' => '\'More testing\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 4
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expectation, $this->phraseCollector->getPhrases());
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector
|
||||
*/
|
||||
class MethodCollectorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var MethodCollector
|
||||
*/
|
||||
protected $methodCollector;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->methodCollector = $this->objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector::parse
|
||||
*/
|
||||
public function testParse()
|
||||
{
|
||||
$file = __DIR__.'/../_files/methodsCode.php.txt';
|
||||
$this->methodCollector->parse($file);
|
||||
$expectation = [
|
||||
[
|
||||
'phrase' => '\'Some string\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 4
|
||||
],
|
||||
[
|
||||
'phrase' => '\'One more string\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 5
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expectation, $this->methodCollector->getPhrases());
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$obj1->___toString('Irrelevant string');
|
||||
$obj2->__('Some string');
|
||||
$obj3->__('One more string');
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
new \Magento\Framework\Phrase('Testing');
|
||||
new Phrase('More testing');
|
||||
new \Magento\Framework\DataObject();
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. 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(): void
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->xmlPhraseCollector = $objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Xml::class
|
||||
);
|
||||
}
|
||||
|
||||
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
@@ -0,0 +1,3 @@
|
||||
$t("text double quote");
|
||||
$t('text single quote');
|
||||
$t('text "some');
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. 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>
|
||||
Reference in New Issue
Block a user