Skip to content

Commit 905f66e

Browse files
author
Natalia Momotenko
committed
Merge remote-tracking branch 'origin/develop' into MAGETWO-55217-new
2 parents 623903e + 3b23563 commit 905f66e

File tree

10 files changed

+424
-12
lines changed

10 files changed

+424
-12
lines changed

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
<preference for="Cm\RedisSession\Handler\LoggerInterface" type="Magento\Framework\Session\SaveHandler\Redis\Logger"/>
153153
<preference for="Magento\Framework\EntityManager\MapperInterface" type="Magento\Framework\EntityManager\CompositeMapper"/>
154154
<preference for="Magento\Framework\Console\CommandListInterface" type="Magento\Framework\Console\CommandList"/>
155+
<preference for="Magento\Framework\DataObject\IdentityGeneratorInterface" type="Magento\Framework\DataObject\IdentityService" />
155156
<type name="Magento\Framework\Model\ResourceModel\Db\TransactionManager" shared="false" />
156157
<type name="Magento\Framework\Logger\Handler\Base">
157158
<arguments>

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
"ext-mbstring": "*",
6565
"ext-openssl": "*",
6666
"ext-zip": "*",
67-
"sjparkinson/static-review": "~4.1"
67+
"sjparkinson/static-review": "~4.1",
68+
"ramsey/uuid": "3.4"
6869
},
6970
"require-dev": {
7071
"phpunit/phpunit": "4.1.0",

composer.lock

Lines changed: 130 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/static/framework/Magento/TestFramework/Inspection/WordsFinder.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class WordsFinder
8686
*/
8787
protected $componentRegistrar;
8888

89+
/**
90+
* Map of phrase to exclude from the file content
91+
*
92+
* @var array
93+
*/
94+
private $exclude = [];
95+
8996
/**
9097
* @param string|array $configFiles
9198
* @param string $baseDir
@@ -172,11 +179,14 @@ protected function _extractWords(\SimpleXMLElement $configXml)
172179
* @param \SimpleXMLElement $configXml
173180
* @return \Magento\TestFramework\Inspection\WordsFinder
174181
* @throws \Magento\TestFramework\Inspection\Exception
182+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
183+
* @SuppressWarnings(PHPMD.NPathComplexity)
175184
*/
176185
protected function _extractWhitelist(\SimpleXMLElement $configXml)
177186
{
178187
// Load whitelist entries
179188
$whitelist = [];
189+
$exclude = [];
180190
$nodes = $configXml->xpath('//config/whitelist/item');
181191
foreach ($nodes as $node) {
182192
$path = $node->xpath('path');
@@ -203,8 +213,21 @@ protected function _extractWhitelist(\SimpleXMLElement $configXml)
203213
$words[] = (string)$wordNode;
204214
}
205215
}
206-
207216
$whitelist[$path] = $words;
217+
218+
$excludeNodes = $node->xpath('exclude');
219+
$excludes = [];
220+
if ($excludeNodes) {
221+
foreach ($excludeNodes as $extractNode) {
222+
$excludes[] = (string)$extractNode;
223+
}
224+
}
225+
226+
if (isset($exclude[$path])) {
227+
$exclude[$path] = array_merge($excludes, $exclude[$path]) ;
228+
} else {
229+
$exclude[$path] = $excludes;
230+
}
208231
}
209232

210233
// Merge with already present whitelist
@@ -214,7 +237,13 @@ protected function _extractWhitelist(\SimpleXMLElement $configXml)
214237
}
215238
$this->_whitelist[$newPath] = array_unique($newWords);
216239
}
217-
240+
241+
foreach ($exclude as $newPath => $newWords) {
242+
if (isset($this->exclude[$newPath])) {
243+
$newWords = array_merge($this->exclude[$newPath], $newWords);
244+
}
245+
$this->exclude[$newPath] = array_unique($newWords);
246+
}
218247
return $this;
219248
}
220249

@@ -254,12 +283,18 @@ public function findWords($file)
254283
* @param string $file
255284
* @return array
256285
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
286+
* @SuppressWarnings(PHPMD.NPathComplexity)
257287
*/
258288
protected function _findWords($file)
259289
{
260290
$checkContents = !$this->_isBinaryFile($file);
261291
$path = $this->getSearchablePath($file);
262292
$contents = $checkContents ? file_get_contents($file) : '';
293+
if (isset($this->exclude[$file]) && !empty($this->exclude[$file])) {
294+
foreach ($this->exclude[$file] as $stringToEliminate) {
295+
$contents = str_replace($stringToEliminate, "", $contents);
296+
}
297+
}
263298

264299
$foundWords = [];
265300
foreach ($this->_words as $word) {

lib/internal/Magento/Framework/DB/Ddl/Trigger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function setTable($name)
187187
(string)new \Magento\Framework\Phrase('Trigger table name should be a string')
188188
);
189189
}
190-
$this->tableName = strtolower($name);
190+
$this->tableName = $name;
191191
return $this;
192192
}
193193

lib/internal/Magento/Framework/DB/Test/Unit/Ddl/TriggerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ public function testSetTableWithException()
8181
$this->_object->setTable($tableName);
8282
}
8383

84+
/**
85+
* Test for table name setter
86+
*/
87+
public function testSetTableName()
88+
{
89+
$names = ['PREFIX_table', 'prefix_table'];
90+
foreach ($names as $name) {
91+
$this->_object->setTable($name);
92+
$this->assertEquals($name, $this->_object->getTable());
93+
}
94+
}
95+
8496
/**
8597
* Test case for getName()
8698
*
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DataObject;
7+
8+
/**
9+
* Interface UuidInterface
10+
*/
11+
interface IdentityGeneratorInterface
12+
{
13+
/**
14+
* Generate id
15+
*
16+
* @return string
17+
**/
18+
public function generateId();
19+
20+
/**
21+
* Generate id for data
22+
*
23+
* @param string $data
24+
* @return string
25+
**/
26+
public function generateIdForData($data);
27+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DataObject;
7+
8+
use Ramsey\Uuid\Uuid;
9+
10+
/**
11+
* Class IdentityService
12+
*/
13+
class IdentityService implements IdentityGeneratorInterface
14+
{
15+
/**
16+
* @var \Ramsey\Uuid\UuidFactoryInterface
17+
*/
18+
private $uuidFactory;
19+
20+
/**
21+
* IdentityService constructor.
22+
* @param \Ramsey\Uuid\UuidFactory $uuidFactory
23+
*/
24+
public function __construct(
25+
\Ramsey\Uuid\UuidFactory $uuidFactory
26+
) {
27+
$this->uuidFactory = $uuidFactory;
28+
}
29+
30+
/**
31+
* @inheritDoc
32+
*/
33+
public function generateId()
34+
{
35+
$uuid = $this->uuidFactory->uuid4();
36+
return $uuid->toString();
37+
}
38+
39+
/**
40+
* @inheritDoc
41+
*/
42+
public function generateIdForData($data)
43+
{
44+
$uuid = $this->uuidFactory->uuid3(Uuid::NAMESPACE_DNS, $data);
45+
return $uuid->toString();
46+
}
47+
}

0 commit comments

Comments
 (0)