Skip to content

Commit d544af3

Browse files
committed
Merge remote-tracking branch 'magento/2.2-develop' into MAGETWO-93990
2 parents bbd3931 + d40a9ec commit d544af3

File tree

188 files changed

+3064
-617
lines changed

Some content is hidden

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

188 files changed

+3064
-617
lines changed

app/bootstrap.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@
5454
&& isset($_SERVER['HTTP_ACCEPT'])
5555
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
5656
) {
57-
$profilerFlag = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
57+
$profilerConfig = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
5858
? $_SERVER['MAGE_PROFILER']
5959
: trim(file_get_contents(BP . '/var/profiler.flag'));
6060

61-
\Magento\Framework\Profiler::applyConfig(
62-
$profilerFlag,
61+
if ($profilerConfig) {
62+
$profilerConfig = json_decode($profilerConfig, true) ?: $profilerConfig;
63+
}
64+
65+
Magento\Framework\Profiler::applyConfig(
66+
$profilerConfig,
6367
BP,
6468
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
6569
);

app/code/Magento/AdminNotification/etc/adminhtml/menu.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
99
<menu>
10-
<add id="Magento_AdminNotification::system_adminnotification" title="Notifications" translate="title" module="Magento_AdminNotification" sortOrder="10" parent="Magento_Backend::system_other_settings" action="adminhtml/notification" resource="Magento_AdminNotification::adminnotification"/>
10+
<add id="Magento_AdminNotification::system_adminnotification" title="Notifications" translate="title" module="Magento_AdminNotification" sortOrder="10" parent="Magento_Backend::system_other_settings" action="adminhtml/notification" resource="Magento_AdminNotification::adminnotification"/>
1111
</menu>
1212
</config>

app/code/Magento/Backend/Block/Media/Uploader.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Backend\Block\Media;
79

810
use Magento\Framework\App\ObjectManager;
911
use Magento\Framework\Serialize\Serializer\Json;
12+
use Magento\Framework\Image\Adapter\ConfigInterface;
1013

1114
/**
1215
* Adminhtml media library uploader
@@ -35,20 +38,29 @@ class Uploader extends \Magento\Backend\Block\Widget
3538
*/
3639
private $jsonEncoder;
3740

41+
/**
42+
* @var ConfigInterface
43+
*/
44+
private $imageConfig;
45+
3846
/**
3947
* @param \Magento\Backend\Block\Template\Context $context
4048
* @param \Magento\Framework\File\Size $fileSize
4149
* @param array $data
4250
* @param Json $jsonEncoder
51+
* @param ConfigInterface $imageConfig
4352
*/
4453
public function __construct(
4554
\Magento\Backend\Block\Template\Context $context,
4655
\Magento\Framework\File\Size $fileSize,
4756
array $data = [],
48-
Json $jsonEncoder = null
57+
Json $jsonEncoder = null,
58+
ConfigInterface $imageConfig = null
4959
) {
5060
$this->_fileSizeService = $fileSize;
5161
$this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class);
62+
$this->imageConfig = $imageConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class);
63+
5264
parent::__construct($context, $data);
5365
}
5466

@@ -90,6 +102,26 @@ public function getFileSizeService()
90102
return $this->_fileSizeService;
91103
}
92104

105+
/**
106+
* Get Image Upload Maximum Width Config
107+
*
108+
* @return int
109+
*/
110+
public function getImageUploadMaxWidth()
111+
{
112+
return $this->imageConfig->getMaxWidth();
113+
}
114+
115+
/**
116+
* Get Image Upload Maximum Height Config
117+
*
118+
* @return int
119+
*/
120+
public function getImageUploadMaxHeight()
121+
{
122+
return $this->imageConfig->getMaxHeight();
123+
}
124+
93125
/**
94126
* Prepares layout and set element renderer
95127
*

app/code/Magento/Backend/Helper/Dashboard/Order.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @api
1414
* @since 100.0.2
1515
*/
16-
class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard
16+
class Order extends AbstractDashboard
1717
{
1818
/**
1919
* @var \Magento\Reports\Model\ResourceModel\Order\Collection
@@ -29,32 +29,25 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard
2929
/**
3030
* @param \Magento\Framework\App\Helper\Context $context
3131
* @param \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
32+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
3233
*/
3334
public function __construct(
3435
\Magento\Framework\App\Helper\Context $context,
35-
\Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
36+
\Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection,
37+
\Magento\Store\Model\StoreManagerInterface $storeManager = null
3638
) {
3739
$this->_orderCollection = $orderCollection;
38-
parent::__construct($context);
39-
}
40+
$this->_storeManager = $storeManager ?: ObjectManager::getInstance()
41+
->get(\Magento\Store\Model\StoreManagerInterface::class);
4042

41-
/**
42-
* The getter function to get the new StoreManager dependency
43-
*
44-
* @return \Magento\Store\Model\StoreManagerInterface
45-
*
46-
* @deprecated 100.1.0
47-
*/
48-
private function getStoreManager()
49-
{
50-
if ($this->_storeManager === null) {
51-
$this->_storeManager = ObjectManager::getInstance()->get(\Magento\Store\Model\StoreManagerInterface::class);
52-
}
53-
return $this->_storeManager;
43+
parent::__construct($context);
5444
}
5545

5646
/**
5747
* @return void
48+
*
49+
* @throws \Magento\Framework\Exception\LocalizedException
50+
* @throws \Magento\Framework\Exception\NoSuchEntityException
5851
*/
5952
protected function _initCollection()
6053
{
@@ -65,15 +58,15 @@ protected function _initCollection()
6558
if ($this->getParam('store')) {
6659
$this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
6760
} elseif ($this->getParam('website')) {
68-
$storeIds = $this->getStoreManager()->getWebsite($this->getParam('website'))->getStoreIds();
61+
$storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
6962
$this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
7063
} elseif ($this->getParam('group')) {
71-
$storeIds = $this->getStoreManager()->getGroup($this->getParam('group'))->getStoreIds();
64+
$storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
7265
$this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
7366
} elseif (!$this->_collection->isLive()) {
7467
$this->_collection->addFieldToFilter(
7568
'store_id',
76-
['eq' => $this->getStoreManager()->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]
69+
['eq' => $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]
7770
);
7871
}
7972
$this->_collection->load();

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,19 @@
319319
</depends>
320320
</field>
321321
</group>
322+
<group id="upload_configuration" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="1">
323+
<label>Images Upload Configuration</label>
324+
<field id="max_width" translate="label comment" type="text" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
325+
<label>Maximum Width</label>
326+
<validate>validate-greater-than-zero validate-number required-entry</validate>
327+
<comment>Maximum allowed width for uploaded image.</comment>
328+
</field>
329+
<field id="max_height" translate="label comment" type="text" sortOrder="200" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
330+
<label>Maximum Height</label>
331+
<validate>validate-greater-than-zero validate-number required-entry</validate>
332+
<comment>Maximum allowed height for uploaded image.</comment>
333+
</field>
334+
</group>
322335
</section>
323336
<section id="admin" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
324337
<label>Admin</label>

app/code/Magento/Backend/etc/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
<dashboard>
2929
<enable_charts>1</enable_charts>
3030
</dashboard>
31+
<upload_configuration>
32+
<max_width>1920</max_width>
33+
<max_height>1200</max_height>
34+
</upload_configuration>
3135
</system>
3236
<general>
3337
<validator_data>

app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
data-mage-init='{
1414
"Magento_Backend/js/media-uploader" : {
1515
"maxFileSize": <?= /* @escapeNotVerified */ $block->getFileSizeService()->getMaxFileSize() ?>,
16-
"maxWidth":<?= /* @escapeNotVerified */ \Magento\Framework\File\Uploader::MAX_IMAGE_WIDTH ?> ,
17-
"maxHeight": <?= /* @escapeNotVerified */ \Magento\Framework\File\Uploader::MAX_IMAGE_HEIGHT ?>
16+
"maxWidth":<?= /* @escapeNotVerified */ $block->getImageUploadMaxWidth() ?> ,
17+
"maxHeight": <?= /* @escapeNotVerified */ $block->getImageUploadMaxHeight() ?>
1818
}
1919
}'
2020
>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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\Braintree\Test\Unit\Model\InstantPurchase\CreditCard;
9+
10+
use Magento\Braintree\Gateway\Config\Config;
11+
use Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker;
12+
13+
/**
14+
* @covers \Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker
15+
*/
16+
class AvailabilityCheckerTest extends \PHPUnit\Framework\TestCase
17+
{
18+
/**
19+
* Testable Object
20+
*
21+
* @var AvailabilityChecker
22+
*/
23+
private $availabilityChecker;
24+
25+
/**
26+
* @var Config|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
private $configMock;
29+
30+
/**
31+
* Set Up
32+
*
33+
* @return void
34+
*/
35+
protected function setUp()
36+
{
37+
$this->configMock = $this->createMock(Config::class);
38+
$this->availabilityChecker = new AvailabilityChecker($this->configMock);
39+
}
40+
41+
/**
42+
* Test isAvailable method
43+
*
44+
* @dataProvider isAvailableDataProvider
45+
*
46+
* @param bool $isVerify3DSecure
47+
* @param bool $expected
48+
*
49+
* @return void
50+
*/
51+
public function testIsAvailable(bool $isVerify3DSecure, bool $expected)
52+
{
53+
$this->configMock->expects($this->once())->method('isVerify3DSecure')->willReturn($isVerify3DSecure);
54+
$actual = $this->availabilityChecker->isAvailable();
55+
self::assertEquals($expected, $actual);
56+
}
57+
58+
/**
59+
* Data provider for isAvailable method test
60+
*
61+
* @return array
62+
*/
63+
public function isAvailableDataProvider()
64+
{
65+
return [
66+
[true, false],
67+
[false, true],
68+
];
69+
}
70+
}

0 commit comments

Comments
 (0)