Skip to content

Commit 5943f27

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-85581
2 parents 9272091 + 169b3eb commit 5943f27

File tree

11 files changed

+429
-133
lines changed

11 files changed

+429
-133
lines changed

app/code/Magento/Customer/Model/FileUploader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function upload()
110110
$result = $fileProcessor->saveTemporaryFile($this->scope . '[' . $this->getAttributeCode() . ']');
111111

112112
// Update tmp_name param. Required for attribute validation!
113-
$result['tmp_name'] = $result['path'] . '/' . ltrim($result['file'], '/');
113+
$result['tmp_name'] = ltrim($result['file'], '/');
114114

115115
$result['url'] = $fileProcessor->getViewUrl(
116116
FileProcessor::TMP_DIR . '/' . ltrim($result['name'], '/'),

app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function testUpload()
140140
'name' => $resultFileName,
141141
'file' => $resultFileName,
142142
'path' => $resultFilePath,
143-
'tmp_name' => $resultFilePath . $resultFileName,
143+
'tmp_name' => ltrim($resultFileName, '/'),
144144
'url' => $resultFileUrl,
145145
];
146146

app/code/Magento/Directory/Setup/UpgradeData.php

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,21 @@ public function __construct(Data $directoryData)
4141
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
4242
{
4343
if (version_compare($context->getVersion(), '2.0.1', '<')) {
44-
$this->addCroatia($setup);
44+
$this->addCountryRegions($setup, $this->getDataForCroatia());
45+
}
46+
if (version_compare($context->getVersion(), '2.0.2', '<')) {
47+
$this->addCountryRegions($setup, $this->getDataForIndia());
4548
}
4649
}
4750

4851
/**
49-
* Add Croatia and it's states to appropriate tables.
52+
* Croatian states data.
5053
*
51-
* @param ModuleDataSetupInterface $setup
52-
* @return void
54+
* @return array
5355
*/
54-
private function addCroatia($setup)
56+
private function getDataForCroatia()
5557
{
56-
/**
57-
* Fill table directory/country_region
58-
* Fill table directory/country_region_name for en_US locale
59-
*/
60-
$data = [
58+
return [
6159
['HR', 'HR-01', 'Zagrebačka županija'],
6260
['HR', 'HR-02', 'Krapinsko-zagorska županija'],
6361
['HR', 'HR-03', 'Sisačko-moslavačka županija'],
@@ -80,6 +78,68 @@ private function addCroatia($setup)
8078
['HR', 'HR-20', 'Međimurska županija'],
8179
['HR', 'HR-21', 'Grad Zagreb']
8280
];
81+
}
82+
83+
/**
84+
* Indian states data.
85+
*
86+
* @return array
87+
*/
88+
private function getDataForIndia()
89+
{
90+
return [
91+
['IN', 'AN', 'Andaman and Nicobar Islands'],
92+
['IN', 'AP', 'Andhra Pradesh'],
93+
['IN', 'AR', 'Arunachal Pradesh'],
94+
['IN', 'AS', 'Assam'],
95+
['IN', 'BR', 'Bihar'],
96+
['IN', 'CH', 'Chandigarh'],
97+
['IN', 'CT', 'Chhattisgarh'],
98+
['IN', 'DN', 'Dadra and Nagar Haveli'],
99+
['IN', 'DD', 'Daman and Diu'],
100+
['IN', 'DL', 'Delhi'],
101+
['IN', 'GA', 'Goa'],
102+
['IN', 'GJ', 'Gujarat'],
103+
['IN', 'HR', 'Haryana'],
104+
['IN', 'HP', 'Himachal Pradesh'],
105+
['IN', 'JK', 'Jammu and Kashmir'],
106+
['IN', 'JH', 'Jharkhand'],
107+
['IN', 'KA', 'Karnataka'],
108+
['IN', 'KL', 'Kerala'],
109+
['IN', 'LD', 'Lakshadweep'],
110+
['IN', 'MP', 'Madhya Pradesh'],
111+
['IN', 'MH', 'Maharashtra'],
112+
['IN', 'MN', 'Manipur'],
113+
['IN', 'ML', 'Meghalaya'],
114+
['IN', 'MZ', 'Mizoram'],
115+
['IN', 'NL', 'Nagaland'],
116+
['IN', 'OR', 'Odisha'],
117+
['IN', 'PY', 'Puducherry'],
118+
['IN', 'PB', 'Punjab'],
119+
['IN', 'RJ', 'Rajasthan'],
120+
['IN', 'SK', 'Sikkim'],
121+
['IN', 'TN', 'Tamil Nadu'],
122+
['IN', 'TG', 'Telangana'],
123+
['IN', 'TR', 'Tripura'],
124+
['IN', 'UP', 'Uttar Pradesh'],
125+
['IN', 'UT', 'Uttarakhand'],
126+
['IN', 'WB', 'West Bengal']
127+
];
128+
}
129+
130+
/**
131+
* Add country regions data to appropriate tables.
132+
*
133+
* @param ModuleDataSetupInterface $setup
134+
* @param array $data
135+
* @return void
136+
*/
137+
private function addCountryRegions(ModuleDataSetupInterface $setup, array $data)
138+
{
139+
/**
140+
* Fill table directory/country_region
141+
* Fill table directory/country_region_name for en_US locale
142+
*/
83143
foreach ($data as $row) {
84144
$bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
85145
$setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);

app/code/Magento/Directory/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Directory" setup_version="2.0.1">
9+
<module name="Magento_Directory" setup_version="2.0.2">
1010
<sequence>
1111
<module name="Magento_Store"/>
1212
</sequence>

app/code/Magento/Reports/Setup/InstallData.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
8383
// @codingStandardsIgnoreStart
8484
$reportLayoutUpdate = '<!--
8585
<referenceContainer name="right">
86-
<action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.viewed</argument></action>
87-
<action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.compared</argument></action>
86+
<referenceBlock name="catalog.compare.sidebar" remove="true" />
8887
</referenceContainer>-->';
8988
// @codingStandardsIgnoreEnd
9089

app/code/Magento/SampleData/Console/Command/SampleDataDeployCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
use Symfony\Component\Console\Command\Command;
1313
use Symfony\Component\Console\Input\ArrayInput;
1414
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Input\InputOption;
1516
use Symfony\Component\Console\Output\OutputInterface;
1617

1718
/**
1819
* Command for deployment of Sample Data
1920
*/
2021
class SampleDataDeployCommand extends Command
2122
{
23+
const OPTION_NO_UPDATE = 'no-update';
24+
2225
/**
2326
* @var \Magento\Framework\Filesystem
2427
*/
@@ -66,6 +69,12 @@ protected function configure()
6669
{
6770
$this->setName('sampledata:deploy')
6871
->setDescription('Deploy sample data modules');
72+
$this->addOption(
73+
self::OPTION_NO_UPDATE,
74+
null,
75+
InputOption::VALUE_NONE,
76+
'Update composer.json without executing composer update'
77+
);
6978
parent::configure();
7079
}
7180

@@ -80,6 +89,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
8089
if (!empty($sampleDataPackages)) {
8190
$baseDir = $this->filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath();
8291
$commonArgs = ['--working-dir' => $baseDir, '--no-progress' => 1];
92+
if ($input->getOption(self::OPTION_NO_UPDATE)) {
93+
$commonArgs['--no-update'] = 1;
94+
}
8395
$packages = [];
8496
foreach ($sampleDataPackages as $name => $version) {
8597
$packages[] = "$name:$version";

app/code/Magento/SampleData/Console/Command/SampleDataRemoveCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Input\InputOption;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213
use Magento\SampleData\Model\Dependency;
1314
use Symfony\Component\Console\Input\ArrayInput;
@@ -22,6 +23,8 @@
2223
*/
2324
class SampleDataRemoveCommand extends Command
2425
{
26+
const OPTION_NO_UPDATE = 'no-update';
27+
2528
/**
2629
* @var Filesystem
2730
*/
@@ -69,6 +72,12 @@ protected function configure()
6972
{
7073
$this->setName('sampledata:remove')
7174
->setDescription('Remove all sample data packages from composer.json');
75+
$this->addOption(
76+
self::OPTION_NO_UPDATE,
77+
null,
78+
InputOption::VALUE_NONE,
79+
'Update composer.json without executing composer update'
80+
);
7281
parent::configure();
7382
}
7483

@@ -81,6 +90,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
8190
if (!empty($sampleDataPackages)) {
8291
$baseDir = $this->filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath();
8392
$commonArgs = ['--working-dir' => $baseDir, '--no-interaction' => 1, '--no-progress' => 1];
93+
if ($input->getOption(self::OPTION_NO_UPDATE)) {
94+
$commonArgs['--no-update'] = 1;
95+
}
8496
$packages = array_keys($sampleDataPackages);
8597
$arguments = array_merge(['command' => 'remove', 'packages' => $packages], $commonArgs);
8698
$commandInput = new ArrayInput($arguments);
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\SampleData\Test\Unit\Console\Command;
7+
8+
use Composer\Console\Application;
9+
use Composer\Console\ApplicationFactory;
10+
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\Framework\Filesystem;
12+
use Magento\Framework\Filesystem\Directory\ReadInterface;
13+
use Magento\Framework\Filesystem\Directory\WriteInterface;
14+
use Magento\SampleData\Model\Dependency;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Component\Console\Input\ArrayInput;
17+
use Symfony\Component\Console\Input\ArrayInputFactory;
18+
19+
/**
20+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
*/
22+
abstract class AbstractSampleDataCommandTest extends TestCase
23+
{
24+
/**
25+
* @var ReadInterface|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
protected $directoryReadMock;
28+
29+
/**
30+
* @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
protected $directoryWriteMock;
33+
34+
/**
35+
* @var Filesystem|\PHPUnit_Framework_MockObject_MockObject
36+
*/
37+
protected $filesystemMock;
38+
39+
/**
40+
* @var Dependency|\PHPUnit_Framework_MockObject_MockObject
41+
*/
42+
protected $sampleDataDependencyMock;
43+
44+
/**
45+
* @var ArrayInputFactory|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
protected $arrayInputFactoryMock;
48+
49+
/**
50+
* @var Application|\PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
protected $applicationMock;
53+
54+
/**
55+
* @var ApplicationFactory|\PHPUnit_Framework_MockObject_MockObject
56+
*/
57+
protected $applicationFactoryMock;
58+
59+
/**
60+
* @return void
61+
*/
62+
protected function setUp()
63+
{
64+
$this->directoryReadMock = $this->createMock(ReadInterface::class);
65+
$this->directoryWriteMock = $this->createMock(WriteInterface::class);
66+
$this->filesystemMock = $this->createMock(Filesystem::class);
67+
$this->sampleDataDependencyMock = $this->createMock(Dependency::class);
68+
$this->arrayInputFactoryMock = $this->createMock(ArrayInputFactory::class);
69+
$this->applicationMock = $this->createMock(Application::class);
70+
$this->applicationFactoryMock = $this->createPartialMock(ApplicationFactory::class, ['create']);
71+
}
72+
73+
/**
74+
* @param array $sampleDataPackages Array in form [package_name => version_constraint]
75+
* @param string $pathToComposerJson Fake path to composer.json
76+
* @param int $appRunResult Composer exit code
77+
* @param array $additionalComposerArgs Additional arguments that composer expects
78+
*/
79+
protected function setupMocks(
80+
$sampleDataPackages,
81+
$pathToComposerJson,
82+
$appRunResult,
83+
$additionalComposerArgs = []
84+
) {
85+
$this->directoryReadMock->expects($this->any())->method('getAbsolutePath')->willReturn($pathToComposerJson);
86+
$this->filesystemMock->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT)->willReturn(
87+
$this->directoryReadMock
88+
);
89+
$this->sampleDataDependencyMock->expects($this->any())->method('getSampleDataPackages')->willReturn(
90+
$sampleDataPackages
91+
);
92+
$this->arrayInputFactoryMock->expects($this->never())->method('create');
93+
94+
$this->applicationMock->expects($this->any())
95+
->method('run')
96+
->with(
97+
new ArrayInput(
98+
array_merge(
99+
$this->expectedComposerArguments(
100+
$sampleDataPackages,
101+
$pathToComposerJson
102+
),
103+
$additionalComposerArgs
104+
)
105+
),
106+
$this->anything()
107+
)
108+
->willReturn($appRunResult);
109+
110+
if (($appRunResult !== 0) && !empty($sampleDataPackages)) {
111+
$this->applicationMock->expects($this->once())->method('resetComposer')->willReturnSelf();
112+
}
113+
114+
$this->applicationFactoryMock->expects($this->any())
115+
->method('create')
116+
->willReturn($this->applicationMock);
117+
}
118+
119+
/**
120+
* Expected arguments for composer based on sample data packages and composer.json path
121+
*
122+
* @param array $sampleDataPackages
123+
* @param string $pathToComposerJson
124+
* @return array
125+
*/
126+
abstract protected function expectedComposerArguments(
127+
array $sampleDataPackages,
128+
string $pathToComposerJson
129+
) : array;
130+
}

0 commit comments

Comments
 (0)