Skip to content

Commit 42feff7

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-42262-custom-vendor' into PR_Branch
2 parents d7f7a5e + 63e600a commit 42feff7

File tree

58 files changed

+450
-442
lines changed

Some content is hidden

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

58 files changed

+450
-442
lines changed

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/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(

0 commit comments

Comments
 (0)