Skip to content

Commit 46bded0

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MC-17259
2 parents f29afc8 + 3397b2b commit 46bded0

File tree

58 files changed

+968
-179
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

+968
-179
lines changed

app/code/Magento/Backup/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<label>Backup Settings</label>
1313
<field id="functionality_enabled" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="0" showInStore="0">
1414
<label>Enable Backup</label>
15-
<comment>Disabled by default for security reasons</comment>
15+
<comment>Disabled by default for security reasons.</comment>
1616
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1717
</field>
1818
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">

app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
<!-- Delete the simple product -->
3333
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
3434

35+
<!-- Delete a Website -->
36+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
37+
<argument name="websiteName" value="Second Website"/>
38+
</actionGroup>
39+
3540
<!-- Log out -->
3641
<actionGroup ref="logout" stepKey="logout"/>
3742
</after>
@@ -135,11 +140,6 @@
135140
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct">
136141
<argument name="product" value="BundleProduct"/>
137142
</actionGroup>
138-
139-
<!-- Delete created Website -->
140-
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
141-
<argument name="websiteName" value="$createWebsite.website[name]$"/>
142-
</actionGroup>
143143
</test>
144144
<test name="AdminCreateAndEditBundleProductOptionsNegativeTest">
145145
<annotations>

app/code/Magento/Catalog/Model/Product/Image/ParamsBuilder.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ private function getWatermark(string $type, int $scopeId = null): array
130130
);
131131

132132
if ($file) {
133-
$size = $this->scopeConfig->getValue(
134-
"design/watermark/{$type}_size",
135-
ScopeInterface::SCOPE_STORE,
136-
$scopeId
133+
$size = explode(
134+
'x',
135+
$this->scopeConfig->getValue(
136+
"design/watermark/{$type}_size",
137+
ScopeInterface::SCOPE_STORE
138+
)
137139
);
138140
$opacity = $this->scopeConfig->getValue(
139141
"design/watermark/{$type}_imageOpacity",
@@ -145,8 +147,8 @@ private function getWatermark(string $type, int $scopeId = null): array
145147
ScopeInterface::SCOPE_STORE,
146148
$scopeId
147149
);
148-
$width = !empty($size['width']) ? $size['width'] : null;
149-
$height = !empty($size['height']) ? $size['height'] : null;
150+
$width = !empty($size['0']) ? $size['0'] : null;
151+
$height = !empty($size['1']) ? $size['1'] : null;
150152

151153
return [
152154
'watermark_file' => $file,

app/code/Magento/Catalog/etc/adminhtml/system.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
</field>
6666
<field id="grid_per_page" translate="label comment" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
6767
<label>Products per Page on Grid Default Value</label>
68-
<comment>Must be in the allowed values list</comment>
68+
<comment>Must be in the allowed values list.</comment>
6969
<validate>validate-per-page-value</validate>
7070
</field>
7171
<field id="list_per_page_values" translate="label comment" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
@@ -75,7 +75,7 @@
7575
</field>
7676
<field id="list_per_page" translate="label comment" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
7777
<label>Products per Page on List Default Value</label>
78-
<comment>Must be in the allowed values list</comment>
78+
<comment>Must be in the allowed values list.</comment>
7979
<validate>validate-per-page-value</validate>
8080
</field>
8181
<field id="flat_catalog_category" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
@@ -90,12 +90,12 @@
9090
</field>
9191
<field id="default_sort_by" translate="label comment" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
9292
<label>Product Listing Sort by</label>
93-
<comment>Applies to category pages</comment>
93+
<comment>Applies to category pages.</comment>
9494
<source_model>Magento\Catalog\Model\Config\Source\ListSort</source_model>
9595
</field>
9696
<field id="list_allow_all" translate="label comment" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
9797
<label>Allow All Products per Page</label>
98-
<comment>Whether to show "All" option in the "Show X Per Page" dropdown</comment>
98+
<comment>Whether to show "All" option in the "Show X Per Page" dropdown.</comment>
9999
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
100100
</field>
101101
<field id="remember_pagination" translate="label comment" type="select" sortOrder="7" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ protected function _prepareIndexTable($entityIds = null)
292292
*/
293293
protected function _updateIndex($entityIds)
294294
{
295+
$this->deleteOldRecords($entityIds);
295296
$connection = $this->getConnection();
296297
$select = $this->_getStockStatusSelect($entityIds, true);
297298
$select = $this->getQueryProcessorComposite()->processQuery($select, $entityIds, true);
@@ -314,7 +315,6 @@ protected function _updateIndex($entityIds)
314315
}
315316
}
316317

317-
$this->deleteOldRecords($entityIds);
318318
$this->_updateIndexTable($data);
319319

320320
return $this;

app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
use Magento\Customer\Api\AddressRepositoryInterface;
1111
use Magento\Customer\Api\Data\AddressInterface;
1212
use Magento\Customer\Api\Data\AddressInterfaceFactory;
13+
use Magento\Directory\Helper\Data as DirectoryData;
14+
use Magento\Framework\Api\DataObjectHelper;
1315
use Magento\Framework\Exception\LocalizedException;
1416
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
15-
use Magento\Framework\Api\DataObjectHelper;
1617

1718
/**
1819
* Create customer address
@@ -38,23 +39,30 @@ class CreateCustomerAddress
3839
* @var DataObjectHelper
3940
*/
4041
private $dataObjectHelper;
42+
/**
43+
* @var DirectoryData
44+
*/
45+
private $directoryData;
4146

4247
/**
4348
* @param GetAllowedAddressAttributes $getAllowedAddressAttributes
4449
* @param AddressInterfaceFactory $addressFactory
4550
* @param AddressRepositoryInterface $addressRepository
4651
* @param DataObjectHelper $dataObjectHelper
52+
* @param DirectoryData $directoryData
4753
*/
4854
public function __construct(
4955
GetAllowedAddressAttributes $getAllowedAddressAttributes,
5056
AddressInterfaceFactory $addressFactory,
5157
AddressRepositoryInterface $addressRepository,
52-
DataObjectHelper $dataObjectHelper
58+
DataObjectHelper $dataObjectHelper,
59+
DirectoryData $directoryData
5360
) {
5461
$this->getAllowedAddressAttributes = $getAllowedAddressAttributes;
5562
$this->addressFactory = $addressFactory;
5663
$this->addressRepository = $addressRepository;
5764
$this->dataObjectHelper = $dataObjectHelper;
65+
$this->directoryData = $directoryData;
5866
}
5967

6068
/**
@@ -102,6 +110,13 @@ public function validateData(array $addressData): void
102110
$attributes = $this->getAllowedAddressAttributes->execute();
103111
$errorInput = [];
104112

113+
//Add error for empty postcode with country with no optional ZIP
114+
if (!$this->directoryData->isZipCodeOptional($addressData['country_id'])
115+
&& (!isset($addressData['postcode']) || empty($addressData['postcode']))
116+
) {
117+
$errorInput[] = 'postcode';
118+
}
119+
105120
foreach ($attributes as $attributeName => $attributeInfo) {
106121
if ($attributeInfo->getIsRequired()
107122
&& (!isset($addressData[$attributeName]) || empty($addressData[$attributeName]))

app/code/Magento/CustomerGraphQl/Model/Resolver/DeleteCustomerAddress.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ public function resolve(
5858
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
5959
}
6060

61-
if (empty($args['id'])) {
62-
throw new GraphQlInputException(__('Address "id" value should be specified'));
63-
}
64-
6561
$address = $this->getCustomerAddress->execute((int)$args['id'], $context->getUserId());
6662
$this->deleteCustomerAddress->execute($address);
6763
return true;

app/code/Magento/CustomerGraphQl/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"type": "magento2-module",
55
"require": {
66
"php": "~7.1.3||~7.2.0||~7.3.0",
7-
"magento/module-customer": "*",
87
"magento/module-authorization": "*",
98
"magento/module-customer": "*",
109
"magento/module-eav": "*",
1110
"magento/module-graph-ql": "*",
1211
"magento/module-newsletter": "*",
1312
"magento/module-integration": "*",
1413
"magento/module-store": "*",
15-
"magento/framework": "*"
14+
"magento/framework": "*",
15+
"magento/module-directory": "*"
1616
},
1717
"license": [
1818
"OSL-3.0",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Developer\Model\Setup\Declaration\Schema\WhitelistGenerator;
1111
use Magento\Framework\Config\FileResolverByModule;
1212
use Magento\Framework\Exception\ConfigurationMismatchException;
13+
use Magento\Framework\Console\Cli;
1314
use Symfony\Component\Console\Command\Command;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Input\InputOption;
@@ -80,11 +81,12 @@ protected function execute(InputInterface $input, OutputInterface $output) : int
8081
$this->whitelistGenerator->generate($moduleName);
8182
} catch (ConfigurationMismatchException $e) {
8283
$output->writeln($e->getMessage());
83-
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
84+
return Cli::RETURN_FAILURE;
8485
} catch (\Exception $e) {
85-
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
86+
$output->writeln($e->getMessage());
87+
return Cli::RETURN_FAILURE;
8688
}
8789

88-
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
90+
return Cli::RETURN_SUCCESS;
8991
}
9092
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Developer\Test\Unit\Console\Command;
9+
10+
use Magento\Developer\Console\Command\TablesWhitelistGenerateCommand as GenerateCommand;
11+
use Magento\Developer\Model\Setup\Declaration\Schema\WhitelistGenerator;
12+
use Magento\Framework\Console\Cli;
13+
use Magento\Framework\Exception\ConfigurationMismatchException as ConfigException;
14+
use PHPUnit\Framework\MockObject\MockObject;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Component\Console\Tester\CommandTester;
17+
18+
/**
19+
* Class TablesWhitelistGenerateCommandTest
20+
*
21+
* @package Magento\Developer\Test\Unit\Console\Command
22+
*/
23+
class TablesWhitelistGenerateCommandTest extends TestCase
24+
{
25+
// Exception Messages!
26+
const CONFIG_EXCEPTION_MESSAGE = 'Configuration Exception Message';
27+
const EXCEPTION_MESSAGE = 'General Exception Message';
28+
29+
/** @var WhitelistGenerator|MockObject $whitelistGenerator */
30+
private $whitelistGenerator;
31+
32+
/** @var GenerateCommand $instance */
33+
private $instance;
34+
35+
protected function setUp()
36+
{
37+
$this->whitelistGenerator = $this->getMockBuilder(WhitelistGenerator::class)
38+
->disableOriginalConstructor()
39+
->getMock();
40+
41+
$this->instance = new GenerateCommand($this->whitelistGenerator);
42+
}
43+
44+
/**
45+
* Test case for success scenario
46+
*
47+
* @param string $arguments
48+
* @param string $expected
49+
*
50+
* @dataProvider successDataProvider
51+
*/
52+
public function testCommandSuccess(string $arguments, string $expected)
53+
{
54+
$this->whitelistGenerator->expects($this->once())
55+
->method('generate')
56+
->with($arguments);
57+
58+
$commandTest = $this->execute($arguments);
59+
$this->assertEquals($expected, $commandTest->getStatusCode());
60+
$this->assertEquals('', $commandTest->getDisplay());
61+
}
62+
63+
/**
64+
* Test case for failure scenario
65+
*
66+
* @param string $arguments
67+
* @param string $expected
68+
* @param \Exception|ConfigException $exception
69+
* @param string $output
70+
*
71+
* @dataProvider failureDataProvider
72+
*/
73+
public function testCommandFailure(string $arguments, string $expected, $exception, string $output)
74+
{
75+
$this->whitelistGenerator->expects($this->once())
76+
->method('generate')
77+
->with($arguments)
78+
->willReturnCallback(
79+
function () use ($exception) {
80+
throw $exception;
81+
}
82+
);
83+
84+
$commandTest = $this->execute($arguments);
85+
$this->assertEquals($expected, $commandTest->getStatusCode());
86+
$this->assertEquals($output . PHP_EOL, $commandTest->getDisplay());
87+
}
88+
89+
/**
90+
* Data provider for success test case
91+
*
92+
* @return array
93+
*/
94+
public function successDataProvider()
95+
{
96+
return [
97+
[
98+
'all',
99+
Cli::RETURN_SUCCESS,
100+
101+
],
102+
[
103+
'Module_Name',
104+
Cli::RETURN_SUCCESS
105+
]
106+
];
107+
}
108+
109+
/**
110+
* Data provider for failure test case
111+
*
112+
* @return array
113+
*/
114+
public function failureDataProvider()
115+
{
116+
return [
117+
[
118+
'all',
119+
Cli::RETURN_FAILURE,
120+
new ConfigException(__('Configuration Exception Message')),
121+
self::CONFIG_EXCEPTION_MESSAGE
122+
],
123+
[
124+
'Module_Name',
125+
Cli::RETURN_FAILURE,
126+
new ConfigException(__('Configuration Exception Message')),
127+
self::CONFIG_EXCEPTION_MESSAGE
128+
],
129+
[
130+
'all',
131+
Cli::RETURN_FAILURE,
132+
new \Exception(self::EXCEPTION_MESSAGE),
133+
self::EXCEPTION_MESSAGE
134+
],
135+
[
136+
'Module_Name',
137+
Cli::RETURN_FAILURE,
138+
new \Exception(self::EXCEPTION_MESSAGE),
139+
self::EXCEPTION_MESSAGE
140+
]
141+
];
142+
}
143+
144+
/**
145+
* Execute command test class for symphony
146+
*
147+
* @param string $arguments
148+
*
149+
* @return CommandTester
150+
*/
151+
private function execute(string $arguments)
152+
{
153+
$commandTest = new CommandTester($this->instance);
154+
$commandTest->execute(['--' . GenerateCommand::MODULE_NAME_KEY => $arguments]);
155+
156+
return $commandTest;
157+
}
158+
}

0 commit comments

Comments
 (0)