Skip to content

Commit 7961175

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into PerformanceToolkitUpdate
2 parents 38fff10 + 7978fcf commit 7961175

File tree

16 files changed

+6963
-23458
lines changed

16 files changed

+6963
-23458
lines changed

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ protected function getConditions()
259259
$conditions = $this->conditionsHelper->decode($conditions);
260260
}
261261

262+
foreach ($conditions as $key => $condition) {
263+
if (!empty($condition['attribute'])
264+
&& in_array($condition['attribute'], ['special_from_date', 'special_to_date'])
265+
) {
266+
$conditions[$key]['value'] = date('Y-m-d H:i:s', strtotime($condition['value']));
267+
}
268+
}
269+
262270
$this->rule->loadPost(['conditions' => $conditions]);
263271
return $this->rule->getConditions();
264272
}

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
288288
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collection);
289289
$this->productsList->setData('conditions_encoded', 'some_serialized_conditions');
290290

291+
$this->widgetConditionsHelper->expects($this->once())
292+
->method('decode')
293+
->with('some_serialized_conditions')
294+
->willReturn([]);
295+
291296
$this->builder->expects($this->once())->method('attachConditionToCollection')
292297
->with($collection, $this->getConditionsForCollection($collection))
293298
->willReturnSelf();

app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\ConfigurableProduct\Model\ConfigurableAttributeData;
1111
use Magento\Customer\Helper\Session\CurrentCustomer;
12+
use Magento\Customer\Model\Session;
1213
use Magento\Framework\App\ObjectManager;
1314
use Magento\Framework\Locale\Format;
1415
use Magento\Framework\Pricing\PriceCurrencyInterface;
@@ -31,6 +32,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
3132
/**
3233
* Current customer
3334
*
35+
* @deprecated, as unused property
3436
* @var CurrentCustomer
3537
*/
3638
protected $currentCustomer;
@@ -67,6 +69,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
6769
*/
6870
private $localeFormat;
6971

72+
/**
73+
* @var Session
74+
*/
75+
private $customerSession;
76+
7077
/**
7178
* @param \Magento\Catalog\Block\Product\Context $context
7279
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -78,6 +85,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
7885
* @param ConfigurableAttributeData $configurableAttributeData
7986
* @param array $data
8087
* @param Format|null $localeFormat
88+
* @param Session|null $customerSession
8189
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8290
*/
8391
public function __construct(
@@ -90,7 +98,8 @@ public function __construct(
9098
PriceCurrencyInterface $priceCurrency,
9199
ConfigurableAttributeData $configurableAttributeData,
92100
array $data = [],
93-
Format $localeFormat = null
101+
Format $localeFormat = null,
102+
Session $customerSession = null
94103
) {
95104
$this->priceCurrency = $priceCurrency;
96105
$this->helper = $helper;
@@ -99,6 +108,7 @@ public function __construct(
99108
$this->currentCustomer = $currentCustomer;
100109
$this->configurableAttributeData = $configurableAttributeData;
101110
$this->localeFormat = $localeFormat ?: ObjectManager::getInstance()->get(Format::class);
111+
$this->customerSession = $customerSession ?: ObjectManager::getInstance()->get(Session::class);
102112

103113
parent::__construct(
104114
$context,
@@ -117,6 +127,7 @@ public function getCacheKeyInfo()
117127
{
118128
$parentData = parent::getCacheKeyInfo();
119129
$parentData[] = $this->priceCurrency->getCurrencySymbol();
130+
$parentData[] = $this->customerSession->getCustomerGroupId();
120131
return $parentData;
121132
}
122133

app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\ConfigurableProduct\Test\Unit\Block\Product\View\Type;
77

8+
use Magento\Customer\Model\Session;
9+
use Magento\Framework\App\State;
10+
811
/**
912
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1013
*/
@@ -65,6 +68,11 @@ class ConfigurableTest extends \PHPUnit\Framework\TestCase
6568
*/
6669
private $storeManager;
6770

71+
/**
72+
* @var \PHPUnit_Framework_MockObject_MockObject
73+
*/
74+
private $customerSession;
75+
6876
protected function setUp()
6977
{
7078
$this->mockContextObject();
@@ -92,6 +100,28 @@ protected function setUp()
92100
->disableOriginalConstructor()
93101
->getMock();
94102

103+
$appState = $this->getMockBuilder(State::class)
104+
->disableOriginalConstructor()
105+
->getMock();
106+
$this->context->expects($this->once())
107+
->method('getAppState')
108+
->willReturn($appState);
109+
$appState->expects($this->any())
110+
->method('getAreaCode')
111+
->willReturn('frontend');
112+
$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
113+
->disableOriginalConstructor()
114+
->getMock();
115+
$this->context->expects($this->once())
116+
->method('getUrlBuilder')
117+
->willReturn($urlBuilder);
118+
$fileResolverMock = $this
119+
->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class)
120+
->disableOriginalConstructor()
121+
->getMock();
122+
$this->context->expects($this->once())
123+
->method('getResolver')
124+
->willReturn($fileResolverMock);
95125
$this->configurableAttributeData = $this->getMockBuilder(
96126
\Magento\ConfigurableProduct\Model\ConfigurableAttributeData::class
97127
)
@@ -102,6 +132,10 @@ protected function setUp()
102132
->disableOriginalConstructor()
103133
->getMock();
104134

135+
$this->customerSession = $this->getMockBuilder(Session::class)
136+
->disableOriginalConstructor()
137+
->getMock();
138+
105139
$this->block = new \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable(
106140
$this->context,
107141
$this->arrayUtils,
@@ -112,10 +146,92 @@ protected function setUp()
112146
$this->priceCurrency,
113147
$this->configurableAttributeData,
114148
[],
115-
$this->localeFormat
149+
$this->localeFormat,
150+
$this->customerSession
116151
);
117152
}
118153

154+
/**
155+
* Provide cache key info
156+
*
157+
* @return array
158+
*/
159+
public function cacheKeyProvider() : array
160+
{
161+
return [
162+
'without_currency_and_customer_group' => [
163+
[
164+
0 => 'BLOCK_TPL',
165+
1 => 'default',
166+
2 => null,
167+
'base_url' => null,
168+
'template' => null,
169+
3 => null,
170+
4 => null,
171+
],
172+
null,
173+
null,
174+
],
175+
'with_customer_group' => [
176+
[
177+
0 => 'BLOCK_TPL',
178+
1 => 'default',
179+
2 => null,
180+
'base_url' => null,
181+
'template' => null,
182+
3 => null,
183+
4 => 1,
184+
],
185+
null,
186+
1,
187+
],
188+
'with_price_currency' => [
189+
[
190+
0 => 'BLOCK_TPL',
191+
1 => 'default',
192+
2 => null,
193+
'base_url' => null,
194+
'template' => null,
195+
3 => '$',
196+
4 => null,
197+
],
198+
'$',
199+
null,
200+
]
201+
];
202+
}
203+
204+
/**
205+
* Test cache Tags
206+
* @dataProvider cacheKeyProvider
207+
* @param array $expected
208+
* @param string|null $priceCurrency
209+
* @param string|null $customerGroupId
210+
*/
211+
public function testGetCacheKeyInfo(array $expected, string $priceCurrency = null, string $customerGroupId = null)
212+
{
213+
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
214+
->setMethods([
215+
'getCurrentCurrency',
216+
])
217+
->getMockForAbstractClass();
218+
$storeMock->expects($this->any())
219+
->method('getCode')
220+
->willReturn('default');
221+
222+
$this->storeManager->expects($this->any())
223+
->method('getStore')
224+
->willReturn($storeMock);
225+
$this->priceCurrency->expects($this->once())
226+
->method('getCurrencySymbol')
227+
->willReturn($priceCurrency);
228+
$this->customerSession->expects($this->once())
229+
->method('getCustomerGroupId')
230+
->willReturn($customerGroupId);
231+
$actual = $this->block->getCacheKeyInfo();
232+
$this->assertEquals($expected, $actual);
233+
}
234+
119235
/**
120236
* Check that getJsonConfig() method returns expected value
121237
*/
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Deploy\Console;
7+
8+
use Magento\Framework\ObjectManagerInterface;
9+
10+
/**
11+
* Provides list of commands to be available for uninstalled application
12+
*/
13+
class CommandList implements \Magento\Framework\Console\CommandListInterface
14+
{
15+
/**
16+
* Object Manager
17+
*
18+
* @var ObjectManagerInterface
19+
*/
20+
private $objectManager;
21+
22+
/**
23+
* @param ObjectManagerInterface $objectManager Object Manager
24+
*/
25+
public function __construct(ObjectManagerInterface $objectManager)
26+
{
27+
$this->objectManager = $objectManager;
28+
}
29+
30+
/**
31+
* Gets list of command classes
32+
*
33+
* @return string[]
34+
*/
35+
private function getCommandsClasses()
36+
{
37+
return [
38+
\Magento\Deploy\Console\Command\App\ConfigImportCommand::class,
39+
];
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function getCommands()
46+
{
47+
$commands = [];
48+
foreach ($this->getCommandsClasses() as $class) {
49+
if (class_exists($class)) {
50+
$commands[] = $this->objectManager->get($class);
51+
} else {
52+
throw new \Exception('Class ' . $class . ' does not exist');
53+
}
54+
}
55+
56+
return $commands;
57+
}
58+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Deploy\Test\Unit\Console;
7+
8+
use Magento\Deploy\Console\Command\App\ConfigImportCommand;
9+
use Magento\Deploy\Console\CommandList;
10+
use Magento\Framework\ObjectManagerInterface;
11+
use PHPUnit\Framework\TestCase;
12+
13+
/**
14+
* @inheritdoc
15+
*/
16+
class CommandListTest extends TestCase
17+
{
18+
/**
19+
* @var CommandList
20+
*/
21+
private $model;
22+
23+
/**
24+
* @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $objectManagerMock;
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
protected function setUp()
32+
{
33+
$this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
34+
->getMockForAbstractClass();
35+
36+
$this->model = new CommandList(
37+
$this->objectManagerMock
38+
);
39+
}
40+
41+
public function testGetCommands()
42+
{
43+
$configImportCommand = $this->getMockBuilder(ConfigImportCommand::class)
44+
->disableOriginalConstructor()
45+
->getMock();
46+
47+
$this->objectManagerMock->expects($this->once())
48+
->method('get')
49+
->willReturnMap([
50+
[ConfigImportCommand::class, $configImportCommand],
51+
]);
52+
53+
$this->assertSame(
54+
[$configImportCommand],
55+
$this->model->getCommands()
56+
);
57+
}
58+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
if (PHP_SAPI == 'cli') {
7+
\Magento\Framework\Console\CommandLocator::register(\Magento\Deploy\Console\CommandList::class);
8+
}

app/code/Magento/Deploy/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"autoload": {
1919
"files": [
20+
"cli_commands.php",
2021
"registration.php"
2122
],
2223
"psr-4": {

app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ public function getConfig()
119119
$configuration['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
120120
$configuration['formKey'] = $this->formKey->getFormKey();
121121
$store = $this->storeManager->getStore();
122-
$configuration['baseUrl'] = $store->isFrontUrlSecure()
123-
? $store->getBaseUrl(UrlInterface::URL_TYPE_LINK, true)
124-
: $store->getBaseUrl(UrlInterface::URL_TYPE_LINK, false);
122+
$configuration['baseUrl'] = $store->getBaseUrl(UrlInterface::URL_TYPE_LINK);
125123
return $configuration;
126124
}
127125

0 commit comments

Comments
 (0)