Skip to content

Commit b978083

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents e37f671 + 80fd646 commit b978083

File tree

11 files changed

+108
-87
lines changed

11 files changed

+108
-87
lines changed

app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
<group value="login"/>
2121
</annotations>
2222

23-
<amOnPage url="{{AdminLoginPage.url}}" stepKey="amOnAdminLoginPage"/>
24-
<fillField selector="{{AdminLoginFormSection.username}}" userInput="{{_ENV.MAGENTO_ADMIN_USERNAME}}" stepKey="fillUsername"/>
25-
<fillField selector="{{AdminLoginFormSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="fillPassword"/>
26-
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickOnSignIn"/>
27-
<closeAdminNotification stepKey="closeAdminNotification"/>
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
2824
<seeInCurrentUrl url="{{AdminLoginPage.url}}" stepKey="seeAdminLoginUrl"/>
25+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
2926
</test>
3027
</tests>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ private function getUsedImagesSelect(): Select
158158
'value as filepath'
159159
)->joinInner(
160160
['image_value' => $this->resourceConnection->getTableName(Gallery::GALLERY_VALUE_TABLE)],
161-
'images.value_id = image_value.value_id'
161+
'images.value_id = image_value.value_id',
162+
[]
162163
)->where(
163164
'images.disabled = 0 AND image_value.disabled = 0'
164165
);

app/code/Magento/Sales/Model/Service/CreditmemoService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected function validateForRefund(\Magento\Sales\Api\Data\CreditmemoInterface
202202
throw new \Magento\Framework\Exception\LocalizedException(
203203
__(
204204
'The most money available to refund is %1.',
205-
$creditmemo->getOrder()->formatPriceTxt($baseAvailableRefund)
205+
$creditmemo->getOrder()->getBaseCurrency()->formatTxt($baseAvailableRefund)
206206
)
207207
);
208208
}

app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,14 @@ public function testRefundExpectsMoneyAvailableToReturn()
351351
$order->method('getBaseTotalPaid')
352352
->willReturn($baseTotalPaid);
353353
$baseAvailableRefund = $baseTotalPaid - $baseTotalRefunded;
354-
$order->method('formatPriceTxt')
354+
$baseCurrency = $this->createMock(\Magento\Directory\Model\Currency::class);
355+
$baseCurrency->expects($this->once())
356+
->method('formatTxt')
355357
->with($baseAvailableRefund)
356358
->willReturn($baseAvailableRefund);
359+
$order->expects($this->once())
360+
->method('getBaseCurrency')
361+
->willReturn($baseCurrency);
357362
$this->creditmemoService->refund($creditMemo, true);
358363
}
359364

@@ -369,4 +374,56 @@ public function testRefundDoNotExpectsId()
369374
$creditMemoMock->expects($this->once())->method('getId')->willReturn(444);
370375
$this->creditmemoService->refund($creditMemoMock, true);
371376
}
377+
378+
/**
379+
* @expectedExceptionMessage The most money available to refund is $1.00.
380+
* @expectedException \Magento\Framework\Exception\LocalizedException
381+
*/
382+
public function testMultiCurrencyRefundExpectsMoneyAvailableToReturn()
383+
{
384+
$baseGrandTotal = 10.00;
385+
$baseTotalRefunded = 9.00;
386+
$baseTotalPaid = 10;
387+
$grandTotal = 8.81;
388+
$totalRefunded = 7.929;
389+
$totalPaid = 8.81;
390+
391+
/** @var CreditmemoInterface|MockObject $creditMemo */
392+
$creditMemo = $this->getMockBuilder(CreditmemoInterface::class)
393+
->setMethods(['getId', 'getOrder'])
394+
->getMockForAbstractClass();
395+
$creditMemo->method('getId')
396+
->willReturn(null);
397+
/** @var Order|MockObject $order */
398+
$order = $this->getMockBuilder(Order::class)
399+
->disableOriginalConstructor()
400+
->getMock();
401+
$creditMemo->method('getOrder')
402+
->willReturn($order);
403+
$creditMemo->method('getBaseGrandTotal')
404+
->willReturn($baseGrandTotal);
405+
$creditMemo->method('getGrandTotal')
406+
->willReturn($grandTotal);
407+
$order->method('getBaseTotalRefunded')
408+
->willReturn($baseTotalRefunded);
409+
$order->method('getTotalRefunded')
410+
->willReturn($totalRefunded);
411+
$this->priceCurrency->method('round')
412+
->withConsecutive([$baseTotalRefunded + $baseGrandTotal], [$baseTotalPaid])
413+
->willReturnOnConsecutiveCalls($baseTotalRefunded + $baseGrandTotal, $baseTotalPaid);
414+
$order->method('getBaseTotalPaid')
415+
->willReturn($baseTotalPaid);
416+
$order->method('getTotalPaid')
417+
->willReturn($totalPaid);
418+
$baseAvailableRefund = $baseTotalPaid - $baseTotalRefunded;
419+
$baseCurrency = $this->createMock(\Magento\Directory\Model\Currency::class);
420+
$baseCurrency->expects($this->once())
421+
->method('formatTxt')
422+
->with($baseAvailableRefund)
423+
->willReturn(sprintf('$%.2f', $baseAvailableRefund));
424+
$order->expects($this->once())
425+
->method('getBaseCurrency')
426+
->willReturn($baseCurrency);
427+
$this->creditmemoService->refund($creditMemo, true);
428+
}
372429
}

app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,11 @@ protected function _joinAttribute($storeId, $attributeCode, $column = null)
257257

258258
// Add attribute value to result set if needed
259259
if (isset($column)) {
260-
$this->_select->columns([
261-
$column => $columnValue
262-
]);
260+
$this->_select->columns(
261+
[
262+
$column => $columnValue
263+
]
264+
);
263265
}
264266
}
265267

@@ -309,6 +311,10 @@ public function getCollection($storeId)
309311
}
310312

311313
$connection = $this->getConnection();
314+
$urlRewriteMetaDataCondition = '';
315+
if (!$this->isCategoryProductURLsConfig($storeId)) {
316+
$urlRewriteMetaDataCondition = ' AND url_rewrite.metadata IS NULL';
317+
}
312318

313319
$this->_select = $connection->select()->from(
314320
['e' => $this->getMainTable()],
@@ -319,7 +325,8 @@ public function getCollection($storeId)
319325
[]
320326
)->joinLeft(
321327
['url_rewrite' => $this->getTable('url_rewrite')],
322-
'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1 AND url_rewrite.metadata IS NULL'
328+
'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1'
329+
. $urlRewriteMetaDataCondition
323330
. $connection->quoteInto(' AND url_rewrite.store_id = ?', $store->getId())
324331
. $connection->quoteInto(' AND url_rewrite.entity_type = ?', ProductUrlRewriteGenerator::ENTITY_TYPE),
325332
['url' => 'request_path']
@@ -483,4 +490,20 @@ private function getProductImageUrl($image)
483490
{
484491
return $this->imageUrlBuilder->getUrl($image, 'product_page_image_large');
485492
}
493+
494+
/**
495+
* Return Use Categories Path for Product URLs config value
496+
*
497+
* @param null|string $storeId
498+
*
499+
* @return bool
500+
*/
501+
private function isCategoryProductURLsConfig($storeId)
502+
{
503+
return $this->scopeConfig->isSetFlag(
504+
HelperProduct::XML_PATH_PRODUCT_URL_USE_CATEGORY,
505+
ScopeInterface::SCOPE_STORE,
506+
$storeId
507+
);
508+
}
486509
}

app/code/Magento/Theme/Controller/Result/AsyncCssPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function beforeSendResponse(Http $subject): void
4141
{
4242
$content = $subject->getContent();
4343

44-
if (strpos($content, '</body') !== false && $this->scopeConfig->isSetFlag(
44+
if (\is_string($content) && strpos($content, '</body') !== false && $this->scopeConfig->isSetFlag(
4545
self::XML_PATH_USE_CSS_CRITICAL_PATH,
4646
ScopeInterface::SCOPE_STORE
4747
)) {

app/design/frontend/Magento/blank/Magento_Theme/layout/default_head_blocks.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<css src="css/styles-m.css"/>
1111
<css src="css/styles-l.css" media="screen and (min-width: 768px)"/>
1212
<css src="css/print.css" media="print"/>
13-
<font src="fonts/opensans/light/opensans-300.woff2"/>
14-
<font src="fonts/opensans/regular/opensans-400.woff2"/>
15-
<font src="fonts/opensans/semibold/opensans-600.woff2"/>
16-
<font src="fonts/opensans/bold/opensans-700.woff2"/>
17-
<font src="fonts/Luma-Icons.woff2"/>
1813
<meta name="format-detection" content="telephone=no"/>
1914
</head>
2015
</page>

app/design/frontend/Magento/luma/Magento_Theme/layout/default_head_blocks.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<head>
1010
<meta name="viewport" content="width=device-width, initial-scale=1"/>
11+
<font src="fonts/opensans/light/opensans-300.woff2"/>
12+
<font src="fonts/opensans/regular/opensans-400.woff2"/>
13+
<font src="fonts/opensans/semibold/opensans-600.woff2"/>
14+
<font src="fonts/opensans/bold/opensans-700.woff2"/>
15+
<font src="fonts/Luma-Icons.woff2"/>
1116
</head>
1217
</page>

dev/tests/static/framework/autoload.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
use \Magento\Framework\App\Filesystem\DirectoryList;
88

9+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
910
$baseDir = realpath(__DIR__ . '/../../../../');
11+
// phpcs:ignore Magento2.Security.IncludeFile.FoundIncludeFile
1012
require $baseDir . '/app/autoload.php';
13+
// phpcs:ignore Magento2.Security.IncludeFile.FoundIncludeFile
1114
require $baseDir . '/vendor/squizlabs/php_codesniffer/autoload.php';
1215
$testsBaseDir = $baseDir . '/dev/tests/static';
1316
$autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader();
@@ -17,6 +20,7 @@
1720
[
1821
$testsBaseDir . '/framework/Magento/TestFramework/',
1922
$testsBaseDir . '/../integration/framework/Magento/TestFramework/',
23+
$testsBaseDir . '/../api-functional/framework/Magento/TestFramework/',
2024
]
2125
);
2226
$autoloadWrapper->addPsr4('Magento\\CodeMessDetector\\', $testsBaseDir . '/framework/Magento/CodeMessDetector');

setup/src/Magento/Setup/Fixtures/CouponCodesFixture.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,54 +71,35 @@ public function execute()
7171

7272
/** @var \Magento\Store\Model\StoreManager $storeManager */
7373
$storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class);
74-
/** @var $category \Magento\Catalog\Model\Category */
75-
$category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class);
7674

7775
//Get all websites
78-
$categoriesArray = [];
76+
$websitesArray = [];
7977
$websites = $storeManager->getWebsites();
8078
foreach ($websites as $website) {
81-
//Get all groups
82-
$websiteGroups = $website->getGroups();
83-
foreach ($websiteGroups as $websiteGroup) {
84-
$websiteGroupRootCategory = $websiteGroup->getRootCategoryId();
85-
$category->load($websiteGroupRootCategory);
86-
$categoryResource = $category->getResource();
87-
//Get all categories
88-
$resultsCategories = $categoryResource->getAllChildren($category);
89-
foreach ($resultsCategories as $resultsCategory) {
90-
$category->load($resultsCategory);
91-
$structure = explode('/', $category->getPath());
92-
if (count($structure) > 2) {
93-
$categoriesArray[] = [$category->getId(), $website->getId()];
94-
}
95-
}
96-
}
79+
$websitesArray[] = $website->getId();
9780
}
98-
asort($categoriesArray);
99-
$categoriesArray = array_values($categoriesArray);
10081

101-
$this->generateCouponCodes($this->ruleFactory, $this->couponCodeFactory, $categoriesArray);
82+
$this->generateCouponCodes($this->ruleFactory, $this->couponCodeFactory, $websitesArray);
10283
}
10384

10485
/**
10586
* Generate Coupon Codes
10687
*
10788
* @param \Magento\SalesRule\Model\RuleFactory $ruleFactory
10889
* @param \Magento\SalesRule\Model\CouponFactory $couponCodeFactory
109-
* @param array $categoriesArray
90+
* @param array $websitesArray
11091
*
11192
* @return void
11293
*/
113-
public function generateCouponCodes($ruleFactory, $couponCodeFactory, $categoriesArray)
94+
public function generateCouponCodes($ruleFactory, $couponCodeFactory, $websitesArray)
11495
{
11596
for ($i = 0; $i < $this->couponCodesCount; $i++) {
11697
$ruleName = sprintf('Coupon Code %1$d', $i);
11798
$data = [
11899
'rule_id' => null,
119100
'name' => $ruleName,
120101
'is_active' => '1',
121-
'website_ids' => $categoriesArray[$i % count($categoriesArray)][1],
102+
'website_ids' => $websitesArray,
122103
'customer_group_ids' => [
123104
0 => '0',
124105
1 => '1',

0 commit comments

Comments
 (0)