Skip to content

Commit bcfe16f

Browse files
Merge pull request #4379 from magento-engcom/2.3-develop-fast-lane-prs
[Magento Community Engineering] Community Contributions - 2.3-develop expedited
2 parents bfa0fd4 + e8b0a53 commit bcfe16f

File tree

5 files changed

+92
-11
lines changed

5 files changed

+92
-11
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/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
}

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');

0 commit comments

Comments
 (0)