Skip to content

Commit 66f13e7

Browse files
author
Oleksii Korshenko
committed
Merge remote-tracking branch 'mainline/2.0' into MAGETWO-61889-upgrade-tests
2 parents e3684af + 10eff9c commit 66f13e7

File tree

66 files changed

+1522
-380
lines changed

Some content is hidden

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

66 files changed

+1522
-380
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function placeCheckoutOrder()
127127
);
128128
} catch (\Exception $exception) {
129129
$result->setData('error', true);
130-
$result->setData('error_messages', __('Cannot place order.'));
130+
$result->setData('error_messages', __('Unable to place order. Please try again later.'));
131131
}
132132
if ($response instanceof Http) {
133133
$response->representJson($this->jsonHelper->jsonEncode($result));

app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function textExecuteFailedPlaceOrderDataProvider()
279279
{
280280
$objectFailed = new \Magento\Framework\DataObject();
281281
$objectFailed->setData('error', true);
282-
$objectFailed->setData('error_messages', __('Cannot place order.'));
282+
$objectFailed->setData('error_messages', __('Unable to place order. Please try again later.'));
283283

284284
return [
285285
[

app/code/Magento/Authorizenet/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Cancel,Cancel
1313
"Something went wrong canceling the transactions.","Something went wrong canceling the transactions."
1414
"There was an error canceling transactions. Please contact us or try again later.","There was an error canceling transactions. Please contact us or try again later."
1515
"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later."
16+
"Unable to place order. Please try again later.","Unable to place order. Please try again later."
1617
"amount %1","amount %1"
1718
failed,failed
1819
successful,successful

app/code/Magento/Braintree/Model/PaymentMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public function assignData(\Magento\Framework\DataObject $data)
269269

270270
$infoInstance->setAdditionalInformation('cc_last4', $additionalData->getData('cc_last4'));
271271
$infoInstance->setAdditionalInformation('cc_token', $additionalData->getData('cc_token'));
272+
$infoInstance->setAdditionalInformation('store_in_vault', $additionalData->getData('store_in_vault'));
272273
$infoInstance->setAdditionalInformation(
273274
'payment_method_nonce',
274275
$additionalData->getData('payment_method_nonce')

app/code/Magento/Braintree/Test/Unit/Model/PaymentMethodTest.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,25 @@ public function testAssignData()
276276
->with($ccExpYear)
277277
->willReturnSelf();
278278

279-
$this->infoInstanceMock->expects($this->atLeastOnce())
279+
$this->infoInstanceMock->expects($this->at(0))
280280
->method('setAdditionalInformation')
281-
->willReturnMap(
282-
[
283-
['device_data', $deviceData],
284-
['cc_last4', $ccLast4],
285-
['cc_token', $ccToken],
286-
['payment_method_nonce', $paymentMethodNonce],
287-
['store_in_vault', $storeInVault]
288-
]
289-
);
281+
->with('device_data', $deviceData);
282+
283+
$this->infoInstanceMock->expects($this->at(1))
284+
->method('setAdditionalInformation')
285+
->with('cc_last4', $ccLast4);
286+
287+
$this->infoInstanceMock->expects($this->at(2))
288+
->method('setAdditionalInformation')
289+
->with('cc_token', $ccToken);
290+
291+
$this->infoInstanceMock->expects($this->at(3))
292+
->method('setAdditionalInformation')
293+
->with('store_in_vault', $storeInVault);
294+
295+
$this->infoInstanceMock->expects($this->at(4))
296+
->method('setAdditionalInformation')
297+
->with('payment_method_nonce', $paymentMethodNonce);
290298

291299
$this->model->assignData($data);
292300
}

app/code/Magento/Catalog/Block/Product/View.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,26 +232,28 @@ public function getJsonConfig()
232232
foreach ($tierPricesList as $tierPrice) {
233233
$tierPrices[] = $this->priceCurrency->convert($tierPrice['price']->getValue());
234234
}
235+
$regularPriceAmount = $product->getPriceInfo()->getPrice('regular_price')->getAmount();
236+
$finalPriceAmount = $product->getPriceInfo()->getPrice('final_price')->getAmount();
235237
$config = [
236238
'productId' => $product->getId(),
237239
'priceFormat' => $this->_localeFormat->getPriceFormat(),
238240
'prices' => [
239241
'oldPrice' => [
240-
'amount' => $this->priceCurrency->convert(
241-
$product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue()
242-
),
242+
'amount' => $regularPriceAmount
243+
? $this->priceCurrency->convert($regularPriceAmount->getValue())
244+
: null,
243245
'adjustments' => []
244246
],
245247
'basePrice' => [
246-
'amount' => $this->priceCurrency->convert(
247-
$product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount()
248-
),
248+
'amount' => $finalPriceAmount
249+
? $this->priceCurrency->convert($finalPriceAmount->getBaseAmount())
250+
: null,
249251
'adjustments' => []
250252
],
251253
'finalPrice' => [
252-
'amount' => $this->priceCurrency->convert(
253-
$product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue()
254-
),
254+
'amount' => $finalPriceAmount
255+
? $this->priceCurrency->convert($finalPriceAmount->getValue())
256+
: null,
255257
'adjustments' => []
256258
]
257259
],
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model\Product\Pricing\Renderer;
8+
9+
/**
10+
* Resolver provided to check is product available for sale
11+
*/
12+
class SalableResolver implements SalableResolverInterface
13+
{
14+
/**
15+
* Check is product available for sale
16+
*
17+
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
18+
* @return boolean
19+
*/
20+
public function isSalable(\Magento\Framework\Pricing\SaleableInterface $salableItem)
21+
{
22+
return $salableItem->getCanShowPrice() !== false && $salableItem->isSalable();
23+
}
24+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model\Product\Pricing\Renderer;
8+
9+
/**
10+
* Interface resolver provided to check is product available for sale
11+
*/
12+
interface SalableResolverInterface
13+
{
14+
/**
15+
* Check is product available for sale
16+
*
17+
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
18+
* @return boolean
19+
*/
20+
public function isSalable(\Magento\Framework\Pricing\SaleableInterface $salableItem);
21+
}

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
use Magento\Framework\Pricing\Render;
1111
use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;
1212
use Magento\Msrp\Pricing\Price\MsrpPrice;
13+
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
14+
use Magento\Framework\View\Element\Template\Context;
15+
use Magento\Framework\Pricing\SaleableInterface;
16+
use Magento\Framework\Pricing\Price\PriceInterface;
17+
use Magento\Framework\Pricing\Render\RendererPool;
1318

1419
/**
1520
* Class for final_price rendering
@@ -19,12 +24,38 @@
1924
*/
2025
class FinalPriceBox extends BasePriceBox
2126
{
27+
/**
28+
* @var SalableResolverInterface
29+
*/
30+
private $salableResolver;
31+
32+
/**
33+
* @param Context $context
34+
* @param SaleableInterface $saleableItem
35+
* @param PriceInterface $price
36+
* @param RendererPool $rendererPool
37+
* @param array $data
38+
* @param SalableResolverInterface $salableResolver
39+
*/
40+
public function __construct(
41+
Context $context,
42+
SaleableInterface $saleableItem,
43+
PriceInterface $price,
44+
RendererPool $rendererPool,
45+
array $data = [],
46+
SalableResolverInterface $salableResolver = null
47+
) {
48+
parent::__construct($context, $saleableItem, $price, $rendererPool, $data);
49+
$this->salableResolver = $salableResolver ?: \Magento\Framework\App\ObjectManager::getInstance()
50+
->get(SalableResolverInterface::class);
51+
}
52+
2253
/**
2354
* @return string
2455
*/
2556
protected function _toHtml()
2657
{
27-
if (!$this->getSaleableItem() || $this->getSaleableItem()->getCanShowPrice() === false) {
58+
if (!$this->salableResolver->isSalable($this->getSaleableItem())) {
2859
return '';
2960
}
3061

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Unit\Model\Product\Pricing\Renderer;
8+
9+
class SalableResolverTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver
13+
*/
14+
protected $object;
15+
16+
/**
17+
* @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
18+
*/
19+
protected $product;
20+
21+
protected function setUp()
22+
{
23+
$this->product = $this->getMock(
24+
'Magento\Catalog\Model\Product',
25+
['__wakeup', 'getCanShowPrice', 'isSalable'],
26+
[],
27+
'',
28+
false
29+
);
30+
31+
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
32+
$this->object = $objectManager->getObject(
33+
'Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver'
34+
);
35+
}
36+
37+
public function testSalableItem()
38+
{
39+
$this->product->expects($this->any())
40+
->method('getCanShowPrice')
41+
->willReturn(true);
42+
43+
$this->product->expects($this->any())->method('isSalable')->willReturn(true);
44+
45+
$result = $this->object->isSalable($this->product);
46+
$this->assertTrue($result);
47+
}
48+
49+
public function testNotSalableItem()
50+
{
51+
$this->product->expects($this->any())
52+
->method('getCanShowPrice')
53+
->willReturn(true);
54+
55+
$this->product->expects($this->any())->method('isSalable')->willReturn(false);
56+
57+
$result = $this->object->isSalable($this->product);
58+
$this->assertFalse($result);
59+
}
60+
}

0 commit comments

Comments
 (0)