Skip to content

Commit d8f13f9

Browse files
committed
Merge branch '2.3-tests-pr' of github.com:magento-pangolin/magento2ce into 2.3-tests-pr
2 parents 2843f3a + 6a68d71 commit d8f13f9

File tree

63 files changed

+1588
-294
lines changed

Some content is hidden

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

63 files changed

+1588
-294
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Class \Magento\Backend\Model\UrlInterface
1414
*
1515
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1617
* @api
1718
* @since 100.0.2
1819
*/
@@ -366,6 +367,19 @@ protected function _getMenu()
366367
return $this->_menu;
367368
}
368369

370+
/**
371+
* Set scope entity
372+
*
373+
* @param mixed $scopeId
374+
* @return \Magento\Framework\UrlInterface
375+
*/
376+
public function setScope($scopeId)
377+
{
378+
parent::setScope($scopeId);
379+
$this->_scope = $this->_scopeResolver->getScope($scopeId);
380+
return $this;
381+
}
382+
369383
/**
370384
* Set custom auth session
371385
*
@@ -402,13 +416,13 @@ public function getAreaFrontName()
402416
}
403417

404418
/**
405-
* Retrieve action path.
406-
* Add backend area front name as a prefix to action path
419+
* Retrieve action path, add backend area front name as a prefix to action path
407420
*
408421
* @return string
409422
*/
410423
protected function _getActionPath()
411424
{
425+
412426
$path = parent::_getActionPath();
413427
if ($path) {
414428
if ($this->getAreaFrontName()) {
@@ -448,8 +462,7 @@ protected function _getConfigCacheId($path)
448462
}
449463

450464
/**
451-
* Get config data by path
452-
* Use only global config values for backend
465+
* Get config data by path, use only global config values for backend
453466
*
454467
* @param string $path
455468
* @return null|string

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Framework\App\Filesystem\DirectoryList;
2020
use Magento\Framework\Exception\FileSystemException;
2121
use Magento\Backend\Block\DataProviders\ImageUploadConfig as ImageUploadConfigDataProvider;
22+
use Magento\MediaStorage\Helper\File\Storage\Database;
2223

2324
/**
2425
* Block for gallery content.
@@ -50,25 +51,34 @@ class Content extends \Magento\Backend\Block\Widget
5051
*/
5152
private $imageUploadConfigDataProvider;
5253

54+
/**
55+
* @var Database
56+
*/
57+
private $fileStorageDatabase;
58+
5359
/**
5460
* @param \Magento\Backend\Block\Template\Context $context
5561
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
5662
* @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig
5763
* @param array $data
5864
* @param ImageUploadConfigDataProvider $imageUploadConfigDataProvider
65+
* @param Database $fileStorageDatabase
5966
*/
6067
public function __construct(
6168
\Magento\Backend\Block\Template\Context $context,
6269
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
6370
\Magento\Catalog\Model\Product\Media\Config $mediaConfig,
6471
array $data = [],
65-
ImageUploadConfigDataProvider $imageUploadConfigDataProvider = null
72+
ImageUploadConfigDataProvider $imageUploadConfigDataProvider = null,
73+
Database $fileStorageDatabase = null
6674
) {
6775
$this->_jsonEncoder = $jsonEncoder;
6876
$this->_mediaConfig = $mediaConfig;
6977
parent::__construct($context, $data);
7078
$this->imageUploadConfigDataProvider = $imageUploadConfigDataProvider
7179
?: ObjectManager::getInstance()->get(ImageUploadConfigDataProvider::class);
80+
$this->fileStorageDatabase = $fileStorageDatabase
81+
?: ObjectManager::getInstance()->get(Database::class);
7282
}
7383

7484
/**
@@ -164,6 +174,13 @@ public function getImagesJson()
164174
$images = $this->sortImagesByPosition($value['images']);
165175
foreach ($images as &$image) {
166176
$image['url'] = $this->_mediaConfig->getMediaUrl($image['file']);
177+
if ($this->fileStorageDatabase->checkDbUsage() &&
178+
!$mediaDir->isFile($this->_mediaConfig->getMediaPath($image['file']))
179+
) {
180+
$this->fileStorageDatabase->saveFileToFilesystem(
181+
$this->_mediaConfig->getMediaPath($image['file'])
182+
);
183+
}
167184
try {
168185
$fileHandler = $mediaDir->stat($this->_mediaConfig->getMediaPath($image['file']));
169186
$image['size'] = $fileHandler['size'];
@@ -187,9 +204,12 @@ public function getImagesJson()
187204
private function sortImagesByPosition($images)
188205
{
189206
if (is_array($images)) {
190-
usort($images, function ($imageA, $imageB) {
191-
return ($imageA['position'] < $imageB['position']) ? -1 : 1;
192-
});
207+
usort(
208+
$images,
209+
function ($imageA, $imageB) {
210+
return ($imageA['position'] < $imageB['position']) ? -1 : 1;
211+
}
212+
);
193213
}
194214
return $images;
195215
}

app/code/Magento/Catalog/Model/Category/FileInfo.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class FileInfo
4343
*/
4444
private $baseDirectory;
4545

46+
/**
47+
* @var ReadInterface
48+
*/
49+
private $pubDirectory;
50+
4651
/**
4752
* @param Filesystem $filesystem
4853
* @param Mime $mime
@@ -82,6 +87,20 @@ private function getBaseDirectory()
8287
return $this->baseDirectory;
8388
}
8489

90+
/**
91+
* Get Pub Directory read instance
92+
*
93+
* @return ReadInterface
94+
*/
95+
private function getPubDirectory()
96+
{
97+
if (!isset($this->pubDirectory)) {
98+
$this->pubDirectory = $this->filesystem->getDirectoryRead(DirectoryList::PUB);
99+
}
100+
101+
return $this->pubDirectory;
102+
}
103+
85104
/**
86105
* Retrieve MIME type of requested file
87106
*
@@ -135,7 +154,7 @@ private function getFilePath($fileName)
135154
{
136155
$filePath = ltrim($fileName, '/');
137156

138-
$mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath();
157+
$mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath($filePath);
139158
$isFileNameBeginsWithMediaDirectoryPath = $this->isBeginsWithMediaDirectoryPath($fileName);
140159

141160
// if the file is not using a relative path, it resides in the catalog/category media directory
@@ -160,7 +179,7 @@ public function isBeginsWithMediaDirectoryPath($fileName)
160179
{
161180
$filePath = ltrim($fileName, '/');
162181

163-
$mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath();
182+
$mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath($filePath);
164183
$isFileNameBeginsWithMediaDirectoryPath = strpos($filePath, $mediaDirectoryRelativeSubpath) === 0;
165184

166185
return $isFileNameBeginsWithMediaDirectoryPath;
@@ -169,14 +188,22 @@ public function isBeginsWithMediaDirectoryPath($fileName)
169188
/**
170189
* Get media directory subpath relative to base directory path
171190
*
191+
* @param string $filePath
172192
* @return string
173193
*/
174-
private function getMediaDirectoryPathRelativeToBaseDirectoryPath()
194+
private function getMediaDirectoryPathRelativeToBaseDirectoryPath(string $filePath = '')
175195
{
176-
$baseDirectoryPath = $this->getBaseDirectory()->getAbsolutePath();
196+
$baseDirectory = $this->getBaseDirectory();
197+
$baseDirectoryPath = $baseDirectory->getAbsolutePath();
177198
$mediaDirectoryPath = $this->getMediaDirectory()->getAbsolutePath();
199+
$pubDirectoryPath = $this->getPubDirectory()->getAbsolutePath();
178200

179201
$mediaDirectoryRelativeSubpath = substr($mediaDirectoryPath, strlen($baseDirectoryPath));
202+
$pubDirectory = $baseDirectory->getRelativePath($pubDirectoryPath);
203+
204+
if (strpos($mediaDirectoryRelativeSubpath, $pubDirectory) === 0 && strpos($filePath, $pubDirectory) !== 0) {
205+
$mediaDirectoryRelativeSubpath = substr($mediaDirectoryRelativeSubpath, strlen($pubDirectory));
206+
}
180207

181208
return $mediaDirectoryRelativeSubpath;
182209
}

app/code/Magento/Catalog/Observer/SetSpecialPriceStartDate.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
3838
{
3939
/** @var $product \Magento\Catalog\Model\Product */
4040
$product = $observer->getEvent()->getProduct();
41-
if ($product->getSpecialPrice() && ! $product->getSpecialFromDate()) {
41+
if ($product->getSpecialPrice() && $product->getSpecialFromDate() === null) {
4242
$product->setData('special_from_date', $this->localeDate->date()->setTime(0, 0));
4343
}
44-
4544
return $this;
4645
}
4746
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminFillProductAttributePropertiesActionGroup">
11+
<arguments>
12+
<argument name="attributeName" type="string"/>
13+
<argument name="attributeType" type="string"/>
14+
</arguments>
15+
<fillField selector="{{AttributePropertiesSection.DefaultLabel}}" userInput="{{attributeName}}" stepKey="fillDefaultLabel"/>
16+
<selectOption selector="{{AttributePropertiesSection.InputType}}" userInput="{{attributeType}}" stepKey="selectInputType"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenAttributeSetByNameActionGroup">
11+
<arguments>
12+
<argument name="attributeSetName" type="string" defaultValue="Default"/>
13+
</arguments>
14+
<click selector="{{AdminProductAttributeSetGridSection.AttributeSetName(attributeSetName)}}" stepKey="chooseAttributeSet"/>
15+
<waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
16+
</actionGroup>
17+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenAttributeSetGridPageActionGroup">
11+
<amOnPage url="{{AdminProductAttributeSetGridPage.url}}" stepKey="goToAttributeSetPage"/>
12+
<waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
13+
</actionGroup>
14+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenProductAttributePageActionGroup">
11+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToAttributePage"/>
12+
<waitForPageLoad stepKey="waitForAttributePageLoad"/>
13+
</actionGroup>
14+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenProductIndexPageActionGroup">
11+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductIndexPage"/>
12+
<waitForPageLoad stepKey="waitForProductIndexPageLoad"/>
13+
</actionGroup>
14+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontCustomProductAttributeActionGroup">
11+
<arguments>
12+
<argument name="attributeLabel" type="string"/>
13+
<argument name="attributeValue" type="string"/>
14+
</arguments>
15+
<see userInput="{{attributeLabel}}" selector="{{StorefrontProductMoreInformationSection.customAttributeLabel(attributeLabel)}}" stepKey="seeAttributeLabel" />
16+
<see userInput="{{attributeValue}}" selector="{{StorefrontProductMoreInformationSection.customAttributeValue(attributeLabel)}}" stepKey="seeAttributeValue" />
17+
</actionGroup>
18+
</actionGroups>

0 commit comments

Comments
 (0)