Skip to content

Commit f3b0daf

Browse files
author
Kopylova,Olga(okopylova)
committed
Merge pull request #265 from magento-ogre/PR_Branch
[Ogres] Bug fixes and custom vendor part 1
2 parents 31a7fe0 + b542481 commit f3b0daf

File tree

62 files changed

+483
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+483
-452
lines changed

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
sudo: required
2+
dist: trusty
3+
14
language: php
25
php:
36
- 5.5
@@ -44,12 +47,10 @@ before_script:
4447
# Install MySQL 5.6, create DB for integration tests
4548
- >
4649
sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ] || [ '$TEST_SUITE' = 'integration_part_2' ] || [ '$TEST_SUITE' = 'integration_integrity' ]; then
47-
sudo apt-get remove --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5;
48-
sudo apt-get autoremove;
49-
sudo apt-get autoclean;
50-
sudo apt-add-repository ppa:ondrej/mysql-5.6 -y;
51-
sudo apt-get update;
52-
sudo apt-get install mysql-server-5.6 mysql-client-5.6;
50+
sudo apt-get remove -y -qq --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5;
51+
sudo apt-get -y -qq autoremove;
52+
sudo apt-get -y -qq autoclean;
53+
sudo apt-get install -y -qq mysql-server-5.6 mysql-client-5.6;
5354
mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; CREATE DATABASE magento_integration_tests;';
5455
mv dev/tests/integration/etc/install-config-mysql.travis.php.dist dev/tests/integration/etc/install-config-mysql.php;
5556
fi"

app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Symfony\Component\Console\Input\InputOption;
1313
use Symfony\Component\Console\Input\InputInterface;
1414
use Symfony\Component\Console\Output\OutputInterface;
15-
use Magento\Framework\App\Filesystem\DirectoryList;
1615

1716
/**
1817
* Class XmlCatalogGenerateCommand Generates dictionary of URNs for the IDE
@@ -42,9 +41,9 @@ class XmlCatalogGenerateCommand extends Command
4241
private $urnResolver;
4342

4443
/**
45-
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
44+
* @var \Magento\Framework\Filesystem\Directory\ReadFactory
4645
*/
47-
private $rootDirRead;
46+
private $readFactory;
4847

4948
/**
5049
* Supported formats
@@ -56,19 +55,19 @@ class XmlCatalogGenerateCommand extends Command
5655
/**
5756
* @param \Magento\Framework\App\Utility\Files $filesUtility
5857
* @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver
59-
* @param \Magento\Framework\Filesystem $filesystemFactory
58+
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
6059
* @param \Magento\Developer\Model\XmlCatalog\Format\FormatInterface[] $formats
6160
*/
6261
public function __construct(
6362
\Magento\Framework\App\Utility\Files $filesUtility,
6463
\Magento\Framework\Config\Dom\UrnResolver $urnResolver,
65-
\Magento\Framework\Filesystem $filesystemFactory,
64+
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
6665
array $formats = []
6766
) {
6867
$this->filesUtility = $filesUtility;
6968
$this->urnResolver = $urnResolver;
7069
$this->formats = $formats;
71-
$this->rootDirRead = $filesystemFactory->getDirectoryRead(DirectoryList::ROOT);
70+
$this->readFactory = $readFactory;
7271
parent::__construct();
7372
}
7473

@@ -111,9 +110,10 @@ private function getUrnDictionary(OutputInterface $output)
111110

112111
$urns = [];
113112
foreach ($files as $file) {
114-
$content = $this->rootDirRead->readFile(
115-
$this->rootDirRead->getRelativePath($file[0])
116-
);
113+
$fileDir = dirname($file[0]);
114+
$fileName = basename($file[0]);
115+
$read = $this->readFactory->create($fileDir);
116+
$content = $read->readFile($fileName);
117117
$matches = [];
118118
preg_match_all('/schemaLocation="(urn\:magento\:[^"]*)"/i', $content, $matches);
119119
if (isset($matches[1])) {

app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,23 @@ public function testExecuteBadType()
4242
)->will($this->returnValue(null));
4343

4444
$formats = ['phpstorm' => $phpstormFormatMock];
45-
$filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
45+
$readFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false);
4646
$readDirMock = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface', [], [], '', false);
4747

4848
$content = file_get_contents($fixtureXmlFile);
4949

50-
$readDirMock->expects($this->once())
51-
->method('getRelativePath')
52-
->with($this->equalTo($fixtureXmlFile))
53-
->will($this->returnValue('test'));
5450
$readDirMock->expects($this->once())
5551
->method('readFile')
56-
->with($this->equalTo('test'))
52+
->with($this->equalTo('test.xml'))
5753
->will($this->returnValue($content));
58-
$filesystem->expects($this->once())
59-
->method('getDirectoryRead')
54+
$readFactory->expects($this->once())
55+
->method('create')
6056
->will($this->returnValue($readDirMock));
6157

6258
$this->command = new XmlCatalogGenerateCommand(
6359
$filesMock,
6460
$urnResolverMock,
65-
$filesystem,
61+
$readFactory,
6662
$formats
6763
);
6864

app/code/Magento/Payment/Model/CcConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function getIcons()
5858
foreach (array_keys($types) as $code) {
5959
if (!array_key_exists($code, $icons)) {
6060
$asset = $this->ccConfig->createAsset('Magento_Payment::images/cc/' . strtolower($code) . '.png');
61-
$placeholder = $this->assetSource->findRelativeSourceFilePath($asset);
61+
$placeholder = $this->assetSource->findSource($asset);
6262
if ($placeholder) {
6363
list($width, $height) = getimagesize($asset->getSourceFile());
6464
$icons[$code] = [

app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testGetConfig()
7777
[$ccAvailableTypesMock['ae']['fileId']]
7878
)->willReturn($assetMock);
7979
$this->assetSourceMock->expects($this->atLeastOnce())
80-
->method('findRelativeSourceFilePath')
80+
->method('findSource')
8181
->with($assetMock)
8282
->willReturnOnConsecutiveCalls(
8383
$ccAvailableTypesMock['vi']['path'],

dev/tests/integration/etc/install-config-mysql.travis.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
return [
88
'db-host' => '127.0.0.1',
9-
'db-user' => 'travis',
9+
'db-user' => 'root',
1010
'db-password' => '',
1111
'db-name' => 'magento_integration_tests',
1212
'db-prefix' => 'trv_',

dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/ReaderTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ public function testXmlConvertedConfigurationAndCompereStructure()
116116
*/
117117
protected function getActualContent()
118118
{
119-
$files = $this->fileUtility->getFiles(
120-
[$this->fileUtility->getPathToSource() . static::ACTUAL],
121-
'config.xml'
122-
);
119+
$files = $this->fileUtility->getFiles([BP . static::ACTUAL], 'config.xml');
123120

124121
return file_get_contents(reset($files));
125122
}
@@ -129,10 +126,7 @@ protected function getActualContent()
129126
*/
130127
protected function getExpectedContent()
131128
{
132-
$files = $this->fileUtility->getFiles(
133-
[$this->fileUtility->getPathToSource() . static::EXPECTED],
134-
'config.xml'
135-
);
129+
$files = $this->fileUtility->getFiles([BP . static::EXPECTED], 'config.xml');
136130

137131
return file_get_contents(reset($files));
138132
}

dev/tests/integration/testsuite/Magento/Setup/Console/Command/I18nCollectPhrasesCommandTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,22 @@ public function testExecuteNonExistingPath()
7575
]
7676
);
7777
}
78+
79+
/**
80+
* @expectedException \InvalidArgumentException
81+
* @expectedExceptionMessage Directory path is not needed when --magento flag is set.
82+
*/
83+
public function testExecuteMagentoFlagDirectoryPath()
84+
{
85+
$this->tester->execute(['directory' => 'a', '--magento' => true]);
86+
}
87+
88+
/**
89+
* @expectedException \InvalidArgumentException
90+
* @expectedExceptionMessage Directory path is needed when --magento flag is not set.
91+
*/
92+
public function testExecuteNoMagentoFlagNoDirectoryPath()
93+
{
94+
$this->tester->execute([]);
95+
}
7896
}

dev/tests/integration/testsuite/Magento/Setup/Console/Command/I18nPackCommandTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,17 @@ public function setUp()
3030

3131
public function tearDown()
3232
{
33-
if (file_exists(__DIR__ . '/_files/output/pack')) {
33+
$this->removeCsv('A');
34+
$this->removeCsv('B');
35+
$this->removeCsv('C');
36+
$this->removeCsv('D');
37+
}
38+
39+
private function removeCsv($module)
40+
{
41+
if (file_exists(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n")) {
3442
$helper = new \Magento\Framework\Backup\Filesystem\Helper();
35-
$helper->rm(__DIR__ . '/_files/output/pack', [], true);
43+
$helper->rm(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n", [], true);
3644
}
3745
}
3846

@@ -41,15 +49,13 @@ public function testExecute()
4149
$this->tester->execute(
4250
[
4351
'source' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/i18n.csv',
44-
'pack' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/output/pack',
4552
'locale' => 'de_DE',
4653
'--allow-duplicates' => true,
4754
]
4855
);
4956

5057
$this->assertEquals('Successfully saved de_DE language package.' . PHP_EOL, $this->tester->getDisplay());
51-
$basePath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/output/pack/'
52-
. 'dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code';
58+
$basePath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code';
5359
$this->assertFileExists($basePath . '/Magento/A/i18n/de_DE.csv');
5460
$this->assertFileExists($basePath . '/Magento/B/i18n/de_DE.csv');
5561
$this->assertFileExists($basePath . '/Magento/C/i18n/de_DE.csv');
@@ -67,7 +73,6 @@ public function testExecuteNonExistingPath()
6773
$this->tester->execute(
6874
[
6975
'source' => $nonExistPath,
70-
'pack' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/output/pack',
7176
'locale' => 'de_DE',
7277
'--allow-duplicates' => true,
7378
]
@@ -83,7 +88,6 @@ public function testExecuteInvalidMode()
8388
$this->tester->execute(
8489
[
8590
'source' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/i18n.csv',
86-
'pack' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/output/pack',
8791
'locale' => 'de_DE',
8892
'--allow-duplicates' => true,
8993
'--mode' => 'invalid'

dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Dictionary/GeneratorTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public function testGenerationWithContext()
104104
{
105105
$this->generator->generate($this->source, $this->outputFileName, true);
106106

107-
$this->assertFileEquals($this->expectedDir . '/with_context.csv', $this->outputFileName);
107+
$expected = explode(PHP_EOL, file_get_contents($this->expectedDir . '/with_context.csv'));
108+
$output = file_get_contents($this->outputFileName);
109+
foreach ($expected as $line) {
110+
if ($line) {
111+
$this->assertContains($line, $output);
112+
}
113+
}
108114
}
109115
}

dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Pack/GeneratorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ protected function setUp()
6161
"/app/code/Magento/FirstModule/i18n/{$this->_locale}.csv",
6262
"/app/code/Magento/SecondModule/i18n/{$this->_locale}.csv",
6363
"/app/design/adminhtml/default/i18n/{$this->_locale}.csv",
64-
"/lib/web/i18n/{$this->_locale}.csv",
6564
];
6665

6766
$this->_generator = ServiceLocator::getPackGenerator();
@@ -92,19 +91,20 @@ public function testGeneration()
9291
ComponentRegistrar::register(
9392
ComponentRegistrar::MODULE,
9493
'Magento_FirstModule',
95-
BP . '/app/code/Magento/FirstModule'
94+
$this->_packPath . '/app/code/Magento/FirstModule'
9695
);
9796
ComponentRegistrar::register(
9897
ComponentRegistrar::MODULE,
9998
'Magento_SecondModule',
100-
BP. '/app/code/Magento/SecondModule'
99+
$this->_packPath. '/app/code/Magento/SecondModule'
101100
);
102101
ComponentRegistrar::register(
103102
ComponentRegistrar::THEME,
104103
'adminhtml/default',
105-
BP. '/app/design/adminhtml/default'
104+
$this->_packPath. '/app/design/adminhtml/default'
106105
);
107-
$this->_generator->generate($this->_dictionaryPath, $this->_packPath, $this->_locale);
106+
107+
$this->_generator->generate($this->_dictionaryPath, $this->_locale);
108108

109109
foreach ($this->_expectedFiles as $file) {
110110
$this->assertFileEquals($this->_expectedDir . $file, $this->_packPath . $file);

dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function allBlocksDataProvider()
7676
}
7777
$templateBlocks = $this->_addBlock($module, $blockClass, $class, $templateBlocks);
7878
}
79+
asort($templateBlocks);
7980
return $templateBlocks;
8081
} catch (\Exception $e) {
8182
trigger_error(

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

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,27 @@ class WordsFinder
7979
*/
8080
protected $_baseDir;
8181

82+
/**
83+
* Component Registrar
84+
*
85+
* @var \Magento\Framework\Component\ComponentRegistrar
86+
*/
87+
protected $componentRegistrar;
88+
8289
/**
8390
* @param string|array $configFiles
8491
* @param string $baseDir
92+
* @param \Magento\Framework\Component\ComponentRegistrar $componentRegistrar
8593
* @param bool $isCopyrightChecked
8694
* @throws \Magento\TestFramework\Inspection\Exception
8795
*/
88-
public function __construct($configFiles, $baseDir, $isCopyrightChecked = false)
96+
public function __construct($configFiles, $baseDir, $componentRegistrar, $isCopyrightChecked = false)
8997
{
9098
if (!is_dir($baseDir)) {
9199
throw new \Magento\TestFramework\Inspection\Exception("Base directory {$baseDir} does not exist");
92100
}
93101
$this->_baseDir = str_replace('\\', '/', realpath($baseDir));
102+
$this->componentRegistrar = $componentRegistrar;
94103

95104
// Load config files
96105
if (!is_array($configFiles)) {
@@ -176,7 +185,15 @@ protected function _extractWhitelist(\SimpleXMLElement $configXml)
176185
'A "path" must be defined for the whitelisted item'
177186
);
178187
}
179-
$path = $this->_baseDir . '/' . (string)$path[0];
188+
$component = $node->xpath('component');
189+
if ($component) {
190+
$componentType = $component[0]->xpath('@type')[0];
191+
$componentName = $component[0]->xpath('@name')[0];
192+
$path = $this->componentRegistrar->getPath((string)$componentType, (string)$componentName)
193+
. '/' . (string)$path[0];
194+
} else {
195+
$path = $this->_baseDir . '/' . (string)$path[0];
196+
}
180197

181198
// Words
182199
$words = [];
@@ -241,13 +258,12 @@ public function findWords($file)
241258
protected function _findWords($file)
242259
{
243260
$checkContents = !$this->_isBinaryFile($file);
244-
245-
$relPath = $this->_getRelPath($file);
261+
$path = $this->getSearchablePath($file);
246262
$contents = $checkContents ? file_get_contents($file) : '';
247263

248264
$foundWords = [];
249265
foreach ($this->_words as $word) {
250-
if (stripos($relPath, $word) !== false || stripos($contents, $word) !== false) {
266+
if (stripos($path, $word) !== false || stripos($contents, $word) !== false) {
251267
$foundWords[] = $word;
252268
}
253269
}
@@ -314,13 +330,16 @@ protected function _removeWhitelistedWords($path, $foundWords)
314330
}
315331

316332
/**
317-
* Return file path relative to base dir
333+
* Return the path for words search
318334
*
319335
* @param string $file
320336
* @return string
321337
*/
322-
protected function _getRelPath($file)
338+
protected function getSearchablePath($file)
323339
{
340+
if (strpos($file, $this->_baseDir) === false) {
341+
return $file;
342+
}
324343
return substr($file, strlen($this->_baseDir) + 1);
325344
}
326345
}

0 commit comments

Comments
 (0)