Skip to content

Commit

Permalink
Merge pull request #4379 from magento-engcom/2.3-develop-fast-lane-prs
Browse files Browse the repository at this point in the history
[Magento Community Engineering] Community Contributions - 2.3-develop expedited
  • Loading branch information
VladimirZaets committed Jun 20, 2019
2 parents bfa0fd4 + e8b0a53 commit bcfe16f
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 11 deletions.
7 changes: 2 additions & 5 deletions app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
<group value="login"/>
</annotations>

<amOnPage url="{{AdminLoginPage.url}}" stepKey="amOnAdminLoginPage"/>
<fillField selector="{{AdminLoginFormSection.username}}" userInput="{{_ENV.MAGENTO_ADMIN_USERNAME}}" stepKey="fillUsername"/>
<fillField selector="{{AdminLoginFormSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="fillPassword"/>
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickOnSignIn"/>
<closeAdminNotification stepKey="closeAdminNotification"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<seeInCurrentUrl url="{{AdminLoginPage.url}}" stepKey="seeAdminLoginUrl"/>
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
</test>
</tests>
2 changes: 1 addition & 1 deletion app/code/Magento/Sales/Model/Service/CreditmemoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ protected function validateForRefund(\Magento\Sales\Api\Data\CreditmemoInterface
throw new \Magento\Framework\Exception\LocalizedException(
__(
'The most money available to refund is %1.',
$creditmemo->getOrder()->formatPriceTxt($baseAvailableRefund)
$creditmemo->getOrder()->getBaseCurrency()->formatTxt($baseAvailableRefund)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,14 @@ public function testRefundExpectsMoneyAvailableToReturn()
$order->method('getBaseTotalPaid')
->willReturn($baseTotalPaid);
$baseAvailableRefund = $baseTotalPaid - $baseTotalRefunded;
$order->method('formatPriceTxt')
$baseCurrency = $this->createMock(\Magento\Directory\Model\Currency::class);
$baseCurrency->expects($this->once())
->method('formatTxt')
->with($baseAvailableRefund)
->willReturn($baseAvailableRefund);
$order->expects($this->once())
->method('getBaseCurrency')
->willReturn($baseCurrency);
$this->creditmemoService->refund($creditMemo, true);
}

Expand All @@ -369,4 +374,56 @@ public function testRefundDoNotExpectsId()
$creditMemoMock->expects($this->once())->method('getId')->willReturn(444);
$this->creditmemoService->refund($creditMemoMock, true);
}

/**
* @expectedExceptionMessage The most money available to refund is $1.00.
* @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testMultiCurrencyRefundExpectsMoneyAvailableToReturn()
{
$baseGrandTotal = 10.00;
$baseTotalRefunded = 9.00;
$baseTotalPaid = 10;
$grandTotal = 8.81;
$totalRefunded = 7.929;
$totalPaid = 8.81;

/** @var CreditmemoInterface|MockObject $creditMemo */
$creditMemo = $this->getMockBuilder(CreditmemoInterface::class)
->setMethods(['getId', 'getOrder'])
->getMockForAbstractClass();
$creditMemo->method('getId')
->willReturn(null);
/** @var Order|MockObject $order */
$order = $this->getMockBuilder(Order::class)
->disableOriginalConstructor()
->getMock();
$creditMemo->method('getOrder')
->willReturn($order);
$creditMemo->method('getBaseGrandTotal')
->willReturn($baseGrandTotal);
$creditMemo->method('getGrandTotal')
->willReturn($grandTotal);
$order->method('getBaseTotalRefunded')
->willReturn($baseTotalRefunded);
$order->method('getTotalRefunded')
->willReturn($totalRefunded);
$this->priceCurrency->method('round')
->withConsecutive([$baseTotalRefunded + $baseGrandTotal], [$baseTotalPaid])
->willReturnOnConsecutiveCalls($baseTotalRefunded + $baseGrandTotal, $baseTotalPaid);
$order->method('getBaseTotalPaid')
->willReturn($baseTotalPaid);
$order->method('getTotalPaid')
->willReturn($totalPaid);
$baseAvailableRefund = $baseTotalPaid - $baseTotalRefunded;
$baseCurrency = $this->createMock(\Magento\Directory\Model\Currency::class);
$baseCurrency->expects($this->once())
->method('formatTxt')
->with($baseAvailableRefund)
->willReturn(sprintf('$%.2f', $baseAvailableRefund));
$order->expects($this->once())
->method('getBaseCurrency')
->willReturn($baseCurrency);
$this->creditmemoService->refund($creditMemo, true);
}
}
31 changes: 27 additions & 4 deletions app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,11 @@ protected function _joinAttribute($storeId, $attributeCode, $column = null)

// Add attribute value to result set if needed
if (isset($column)) {
$this->_select->columns([
$column => $columnValue
]);
$this->_select->columns(
[
$column => $columnValue
]
);
}
}

Expand Down Expand Up @@ -309,6 +311,10 @@ public function getCollection($storeId)
}

$connection = $this->getConnection();
$urlRewriteMetaDataCondition = '';
if (!$this->isCategoryProductURLsConfig($storeId)) {
$urlRewriteMetaDataCondition = ' AND url_rewrite.metadata IS NULL';
}

$this->_select = $connection->select()->from(
['e' => $this->getMainTable()],
Expand All @@ -319,7 +325,8 @@ public function getCollection($storeId)
[]
)->joinLeft(
['url_rewrite' => $this->getTable('url_rewrite')],
'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1 AND url_rewrite.metadata IS NULL'
'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1'
. $urlRewriteMetaDataCondition
. $connection->quoteInto(' AND url_rewrite.store_id = ?', $store->getId())
. $connection->quoteInto(' AND url_rewrite.entity_type = ?', ProductUrlRewriteGenerator::ENTITY_TYPE),
['url' => 'request_path']
Expand Down Expand Up @@ -483,4 +490,20 @@ private function getProductImageUrl($image)
{
return $this->imageUrlBuilder->getUrl($image, 'product_page_image_large');
}

/**
* Return Use Categories Path for Product URLs config value
*
* @param null|string $storeId
*
* @return bool
*/
private function isCategoryProductURLsConfig($storeId)
{
return $this->scopeConfig->isSetFlag(
HelperProduct::XML_PATH_PRODUCT_URL_USE_CATEGORY,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
}
4 changes: 4 additions & 0 deletions dev/tests/static/framework/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

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

//phpcs:ignore Magento2.Functions.DiscouragedFunction
$baseDir = realpath(__DIR__ . '/../../../../');
// phpcs:ignore Magento2.Security.IncludeFile.FoundIncludeFile
require $baseDir . '/app/autoload.php';
// phpcs:ignore Magento2.Security.IncludeFile.FoundIncludeFile
require $baseDir . '/vendor/squizlabs/php_codesniffer/autoload.php';
$testsBaseDir = $baseDir . '/dev/tests/static';
$autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader();
Expand All @@ -17,6 +20,7 @@
[
$testsBaseDir . '/framework/Magento/TestFramework/',
$testsBaseDir . '/../integration/framework/Magento/TestFramework/',
$testsBaseDir . '/../api-functional/framework/Magento/TestFramework/',
]
);
$autoloadWrapper->addPsr4('Magento\\CodeMessDetector\\', $testsBaseDir . '/framework/Magento/CodeMessDetector');
Expand Down

0 comments on commit bcfe16f

Please sign in to comment.