-
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.
Merge pull request #1223 from magento-tsg/MAGETWO-67048
[TSGAB] MAGETWO-67048: Cannot add translate attribute into the di.xml
- Loading branch information
Showing
7 changed files
with
159 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
27 changes: 27 additions & 0 deletions
27
lib/internal/Magento/Framework/Config/Converter/Dom/DiFlat.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,27 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Framework\Config\Converter\Dom; | ||
|
||
/** | ||
* Converter of XML data to an array representation with no data loss excluding argument translation. | ||
*/ | ||
class DiFlat extends Flat | ||
{ | ||
/** | ||
* Retrieve key-value pairs of node attributes excluding translate attribute. | ||
* | ||
* @param \DOMNode $node | ||
* @return array | ||
*/ | ||
protected function getNodeAttributes(\DOMNode $node) | ||
{ | ||
$result = parent::getNodeAttributes($node); | ||
unset($result['translate']); | ||
|
||
return $result; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
lib/internal/Magento/Framework/Config/Test/Unit/Converter/Dom/DiFlatTest.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,55 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Framework\Config\Test\Unit\Converter\Dom; | ||
|
||
/** | ||
* Class DiFlatTest @covers \Magento\Framework\Config\Converter\Dom\DiFlat | ||
*/ | ||
class DiFlatTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Test subject. | ||
* | ||
* @var \Magento\Framework\Config\Converter\Dom\DiFlat | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$arrayNodeConfig = new \Magento\Framework\Config\Dom\ArrayNodeConfig( | ||
new \Magento\Framework\Config\Dom\NodePathMatcher(), | ||
[ | ||
'/root/multipleNode' => 'id', | ||
'/root/wrongArray' => 'id', | ||
], | ||
[ | ||
'/root/node_one/subnode', | ||
] | ||
); | ||
$this->model = new \Magento\Framework\Config\Converter\Dom\DiFlat($arrayNodeConfig); | ||
} | ||
|
||
/** | ||
* Test \Magento\Framework\Config\Converter\Dom\DiFlat::convert() exclude attribute 'translate'. | ||
* | ||
* @covers \Magento\Framework\Config\Converter\Dom\DiFlat::convert() | ||
*/ | ||
public function testConvert() | ||
{ | ||
$fixturePath = __DIR__ . '/../../_files/converter/dom/flat/'; | ||
$expected = require $fixturePath . 'result.php'; | ||
|
||
$dom = new \DOMDocument(); | ||
$dom->load($fixturePath . 'di_source.xml'); | ||
|
||
$actual = $this->model->convert($dom); | ||
$this->assertEquals($expected, $actual); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
lib/internal/Magento/Framework/Config/Test/Unit/_files/converter/dom/flat/di_source.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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<root> | ||
<node_one attributeOne = '10' attributeTwo = '20' translate="true" > | ||
<subnode attributeThree = '30' translate="true" ></subnode> | ||
<subnode attributeThree = '40' attributeFour = '40' translate="true" >Value1</subnode> | ||
<books attributeFive = '50' translate="true" /> | ||
</node_one> | ||
<multipleNode id="one" name="name1" translate="true" > | ||
<value>1</value> | ||
</multipleNode> | ||
<multipleNode id="two" name="name2" translate="true" > | ||
<value>2</value> | ||
</multipleNode> | ||
<someOtherVal translate="true" ></someOtherVal> | ||
<someDataVal translate="true" ><![CDATA[]]></someDataVal> | ||
</root> |
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