Skip to content

Commit 36e6d8b

Browse files
Devagouda PatilDevagouda Patil
authored andcommitted
Merge branch '2.3-develop' into MAGETWO-96194-random-failure-tax-test
2 parents cbacef5 + 069d5cd commit 36e6d8b

File tree

212 files changed

+6653
-848
lines changed

Some content is hidden

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

212 files changed

+6653
-848
lines changed

app/code/Magento/Backend/Model/AdminPathConfig.php

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,37 @@ public function __construct(
4848
}
4949

5050
/**
51-
* {@inheritdoc}
52-
*
53-
* @param \Magento\Framework\App\RequestInterface $request
54-
* @return string
51+
* @inheritdoc
5552
*/
5653
public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
5754
{
5855
return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
5956
}
6057

6158
/**
62-
* {@inheritdoc}
63-
*
64-
* @param string $path
65-
* @return bool
59+
* @inheritdoc
6660
*/
6761
public function shouldBeSecure($path)
6862
{
69-
return parse_url(
70-
(string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default'),
71-
PHP_URL_SCHEME
72-
) === 'https'
73-
|| $this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)
74-
&& parse_url(
75-
(string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default'),
76-
PHP_URL_SCHEME
77-
) === 'https';
63+
$baseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
64+
if (parse_url($baseUrl, PHP_URL_SCHEME) === 'https') {
65+
return true;
66+
}
67+
68+
if ($this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)) {
69+
if ($this->backendConfig->isSetFlag('admin/url/use_custom')) {
70+
$adminBaseUrl = (string)$this->coreConfig->getValue('admin/url/custom', 'default');
71+
} else {
72+
$adminBaseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
73+
}
74+
return parse_url($adminBaseUrl, PHP_URL_SCHEME) === 'https';
75+
}
76+
77+
return false;
7878
}
7979

8080
/**
81-
* {@inheritdoc}
82-
*
83-
* @return string
81+
* @inheritdoc
8482
*/
8583
public function getDefaultPath()
8684
{

app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<page name="WebConfigurationPage" url="admin/system_config/edit/section/web/" area="admin" module="Backend">
1515
<section name="WYSIWYGOptionsSection"/>
1616
</page>
17+
<page name="GeneralConfigurationPage" url="admin/system_config/edit/section/general/" area="admin" module="Backend">
18+
<section name="LocaleOptionsSection"/>
19+
</page>
1720
</pages>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="LocaleOptionsSection">
12+
<element name="sectionHeader" type="text" selector="#general_locale-head"/>
13+
<element name="timezone" type="select" selector="#general_locale_timezone"/>
14+
</section>
15+
</sections>

app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,35 @@ public function testGetCurrentSecureUrl()
7676
* @param $unsecureBaseUrl
7777
* @param $useSecureInAdmin
7878
* @param $secureBaseUrl
79+
* @param $useCustomUrl
80+
* @param $customUrl
7981
* @param $expected
8082
* @dataProvider shouldBeSecureDataProvider
8183
*/
82-
public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
83-
{
84-
$coreConfigValueMap = [
84+
public function testShouldBeSecure(
85+
$unsecureBaseUrl,
86+
$useSecureInAdmin,
87+
$secureBaseUrl,
88+
$useCustomUrl,
89+
$customUrl,
90+
$expected
91+
) {
92+
$coreConfigValueMap = $this->returnValueMap([
8593
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl],
8694
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl],
87-
];
88-
$this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
89-
$this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
95+
['admin/url/custom', 'default', null, $customUrl],
96+
]);
97+
$backendConfigFlagsMap = $this->returnValueMap([
98+
[\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, $useSecureInAdmin],
99+
['admin/url/use_custom', $useCustomUrl],
100+
]);
101+
$this->coreConfig->expects($this->atLeast(1))->method('getValue')
102+
->will($coreConfigValueMap);
103+
$this->coreConfig->expects($this->atMost(2))->method('getValue')
104+
->will($coreConfigValueMap);
105+
106+
$this->backendConfig->expects($this->atMost(2))->method('isSetFlag')
107+
->will($backendConfigFlagsMap);
90108
$this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
91109
}
92110

@@ -96,13 +114,13 @@ public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureB
96114
public function shouldBeSecureDataProvider()
97115
{
98116
return [
99-
['http://localhost/', false, 'default', false],
100-
['http://localhost/', true, 'default', false],
101-
['https://localhost/', false, 'default', true],
102-
['https://localhost/', true, 'default', true],
103-
['http://localhost/', false, 'https://localhost/', false],
104-
['http://localhost/', true, 'https://localhost/', true],
105-
['https://localhost/', true, 'https://localhost/', true],
117+
['http://localhost/', false, 'default', false, '', false],
118+
['http://localhost/', true, 'default', false, '', false],
119+
['https://localhost/', false, 'default', false, '', true],
120+
['https://localhost/', true, 'default', false, '', true],
121+
['http://localhost/', false, 'https://localhost/', false, '', false],
122+
['http://localhost/', true, 'https://localhost/', false, '', true],
123+
['https://localhost/', true, 'https://localhost/', false, '', true],
106124
];
107125
}
108126

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(
9090
}
9191

9292
/**
93-
* {@inheritdoc}
93+
* @inheritdoc
9494
*/
9595
public function get($sku, $optionId)
9696
{
@@ -106,23 +106,24 @@ public function get($sku, $optionId)
106106

107107
$productLinks = $this->linkManagement->getChildren($product->getSku(), $optionId);
108108

109-
/** @var \Magento\Bundle\Api\Data\OptionInterface $option */
109+
/** @var \Magento\Bundle\Api\Data\OptionInterface $optionDataObject */
110110
$optionDataObject = $this->optionFactory->create();
111111
$this->dataObjectHelper->populateWithArray(
112112
$optionDataObject,
113113
$option->getData(),
114114
\Magento\Bundle\Api\Data\OptionInterface::class
115115
);
116-
$optionDataObject->setOptionId($option->getId())
117-
->setTitle($option->getTitle() === null ? $option->getDefaultTitle() : $option->getTitle())
118-
->setSku($product->getSku())
119-
->setProductLinks($productLinks);
116+
117+
$optionDataObject->setOptionId($option->getId());
118+
$optionDataObject->setTitle($option->getTitle() === null ? $option->getDefaultTitle() : $option->getTitle());
119+
$optionDataObject->setSku($product->getSku());
120+
$optionDataObject->setProductLinks($productLinks);
120121

121122
return $optionDataObject;
122123
}
123124

124125
/**
125-
* {@inheritdoc}
126+
* @inheritdoc
126127
*/
127128
public function getList($sku)
128129
{
@@ -131,6 +132,8 @@ public function getList($sku)
131132
}
132133

133134
/**
135+
* Return list of product options
136+
*
134137
* @param ProductInterface $product
135138
* @return \Magento\Bundle\Api\Data\OptionInterface[]
136139
*/
@@ -140,7 +143,7 @@ public function getListByProduct(ProductInterface $product)
140143
}
141144

142145
/**
143-
* {@inheritdoc}
146+
* @inheritdoc
144147
*/
145148
public function delete(\Magento\Bundle\Api\Data\OptionInterface $option)
146149
{
@@ -156,20 +159,19 @@ public function delete(\Magento\Bundle\Api\Data\OptionInterface $option)
156159
}
157160

158161
/**
159-
* {@inheritdoc}
162+
* @inheritdoc
160163
*/
161164
public function deleteById($sku, $optionId)
162165
{
163-
$product = $this->getProduct($sku);
164-
$optionCollection = $this->type->getOptionsCollection($product);
165-
$optionCollection->setIdFilter($optionId);
166-
$hasBeenDeleted = $this->delete($optionCollection->getFirstItem());
166+
/** @var \Magento\Bundle\Api\Data\OptionInterface $option */
167+
$option = $this->get($sku, $optionId);
168+
$hasBeenDeleted = $this->delete($option);
167169

168170
return $hasBeenDeleted;
169171
}
170172

171173
/**
172-
* {@inheritdoc}
174+
* @inheritdoc
173175
*/
174176
public function save(
175177
\Magento\Catalog\Api\Data\ProductInterface $product,
@@ -189,6 +191,9 @@ public function save(
189191
* @param \Magento\Catalog\Api\Data\ProductInterface $product
190192
* @param \Magento\Bundle\Api\Data\OptionInterface $option
191193
* @return $this
194+
* @throws InputException
195+
* @throws NoSuchEntityException
196+
* @throws \Magento\Framework\Exception\CouldNotSaveException
192197
*/
193198
protected function updateOptionSelection(
194199
\Magento\Catalog\Api\Data\ProductInterface $product,
@@ -228,9 +233,12 @@ protected function updateOptionSelection(
228233
}
229234

230235
/**
236+
* Retrieve product by SKU
237+
*
231238
* @param string $sku
232239
* @return \Magento\Catalog\Api\Data\ProductInterface
233-
* @throws \Magento\Framework\Exception\InputException
240+
* @throws InputException
241+
* @throws NoSuchEntityException
234242
*/
235243
private function getProduct($sku)
236244
{

app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Bundle\Test\Unit\Model;
99

1010
use Magento\Bundle\Model\OptionRepository;
11+
use Magento\Framework\Exception\NoSuchEntityException;
1112

1213
/**
1314
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -84,7 +85,7 @@ protected function setUp()
8485
->getMock();
8586
$this->optionResourceMock = $this->createPartialMock(
8687
\Magento\Bundle\Model\ResourceModel\Option::class,
87-
['delete', '__wakeup', 'save', 'removeOptionSelections']
88+
['get', 'delete', '__wakeup', 'save', 'removeOptionSelections']
8889
);
8990
$this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
9091
$this->linkManagementMock = $this->createMock(\Magento\Bundle\Api\ProductLinkManagementInterface::class);
@@ -227,32 +228,92 @@ public function testDeleteThrowsExceptionIfCannotDelete()
227228
$this->model->delete($optionMock);
228229
}
229230

231+
/**
232+
* Test successful delete action for given $optionId
233+
*/
230234
public function testDeleteById()
231235
{
232236
$productSku = 'sku';
233237
$optionId = 100;
234-
$productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class);
238+
239+
$optionMock = $this->createMock(\Magento\Bundle\Model\Option::class);
240+
$optionMock->expects($this->exactly(2))
241+
->method('getId')
242+
->willReturn($optionId);
243+
244+
$optionMock->expects($this->once())
245+
->method('getData')
246+
->willReturn([
247+
'title' => 'Option title',
248+
'option_id' => $optionId
249+
]);
250+
251+
$this->optionFactoryMock->expects($this->once())
252+
->method('create')
253+
->willReturn($optionMock);
254+
255+
$productMock = $this->createPartialMock(
256+
\Magento\Catalog\Model\Product::class,
257+
['getTypeId', 'getTypeInstance', 'getStoreId', 'getPriceType', '__wakeup', 'getSku']
258+
);
235259
$productMock->expects($this->once())
236260
->method('getTypeId')
237261
->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
238-
$this->productRepositoryMock->expects($this->once())
262+
$productMock->expects($this->exactly(2))->method('getSku')->willReturn($productSku);
263+
264+
$this->productRepositoryMock
265+
->expects($this->once())
239266
->method('get')
240267
->with($productSku)
241268
->willReturn($productMock);
242269

270+
$optCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class);
271+
$optCollectionMock->expects($this->once())->method('getItemById')->with($optionId)->willReturn($optionMock);
272+
$this->typeMock->expects($this->once())
273+
->method('getOptionsCollection')
274+
->with($productMock)
275+
->willReturn($optCollectionMock);
276+
277+
$this->assertTrue($this->model->deleteById($productSku, $optionId));
278+
}
279+
280+
/**
281+
* Tests if NoSuchEntityException thrown when provided $optionId not found
282+
*/
283+
public function testDeleteByIdException()
284+
{
285+
$productSku = 'sku';
286+
$optionId = null;
287+
243288
$optionMock = $this->createMock(\Magento\Bundle\Model\Option::class);
289+
$optionMock->expects($this->exactly(1))
290+
->method('getId')
291+
->willReturn($optionId);
292+
293+
$productMock = $this->createPartialMock(
294+
\Magento\Catalog\Model\Product::class,
295+
['getTypeId', 'getTypeInstance', 'getStoreId', 'getPriceType', '__wakeup', 'getSku']
296+
);
297+
$productMock->expects($this->once())
298+
->method('getTypeId')
299+
->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
300+
301+
$this->productRepositoryMock
302+
->expects($this->once())
303+
->method('get')
304+
->with($productSku)
305+
->willReturn($productMock);
244306

245307
$optCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class);
308+
$optCollectionMock->expects($this->once())->method('getItemById')->with($optionId)->willReturn($optionMock);
246309
$this->typeMock->expects($this->once())
247310
->method('getOptionsCollection')
248311
->with($productMock)
249312
->willReturn($optCollectionMock);
250313

251-
$optCollectionMock->expects($this->once())->method('setIdFilter')->with($optionId)->willReturnSelf();
252-
$optCollectionMock->expects($this->once())->method('getFirstItem')->willReturn($optionMock);
314+
$this->expectException(NoSuchEntityException::class);
253315

254-
$this->optionResourceMock->expects($this->once())->method('delete')->with($optionMock)->willReturnSelf();
255-
$this->assertTrue($this->model->deleteById($productSku, $optionId));
316+
$this->model->deleteById($productSku, $optionId);
256317
}
257318

258319
/**

0 commit comments

Comments
 (0)