Skip to content

Commit babf3bf

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-37571' into MAGETWO-5403
2 parents 13a1445 + a4fb6b4 commit babf3bf

File tree

4 files changed

+90
-29
lines changed

4 files changed

+90
-29
lines changed

app/code/Magento/Catalog/view/base/templates/product/price/tier_prices.phtml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,26 @@ $product = $block->getSaleableItem();
5858
data-tier-price="<?php echo $block->escapeHtml($block->jsonEncode($tierPriceData)); ?>">
5959
<?php echo __('Click for price'); ?></a>
6060
<?php else:
61-
echo __(
62-
'Buy %1 for %2',
63-
$price['price_qty'],
64-
$block->renderAmount(
65-
$price['price'],
66-
[
67-
'price_id' => $index,
68-
'id_suffix' => '-' . $index,
69-
'include_container' => true,
70-
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_OPTION
71-
]
72-
)
61+
$priceAmountBlock = $block->renderAmount(
62+
$price['price'],
63+
[
64+
'price_id' => $index,
65+
'id_suffix' => '-' . $index,
66+
'include_container' => true,
67+
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_OPTION
68+
]
7369
);
74-
?><?php echo __('each') ?>
75-
<?php if ($block->getShowDetailedPrice() !== false): ?>
76-
&nbsp;<?php echo __('and') ?>&nbsp;<strong class="benefit"><?php echo __('save')?>
77-
<span class="percent tier-<?php echo $index ?>">&nbsp;<?php echo $tierPriceModel->getSavePercent($price['price']) ?></span>%
78-
</strong>
79-
<?php endif ?>
70+
?>
71+
<?php echo ($block->getShowDetailedPrice() !== false)
72+
? __(
73+
'Buy %1 for %2 each and <strong class="benefit">save<span class="percent tier-%3">&nbsp;%4</span>%</strong>',
74+
$price['price_qty'],
75+
$priceAmountBlock,
76+
$index,
77+
$tierPriceModel->getSavePercent($price['price'])
78+
)
79+
: __('Buy %1 for %2 each', $price['price_qty'], $priceAmountBlock);
80+
?>
8081
<?php endif; ?>
8182
</li>
8283
<?php endforeach; ?>

app/code/Magento/Payment/Model/IframeConfigProvider.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ abstract class IframeConfigProvider implements ConfigProviderInterface
3535
*/
3636
protected $logger;
3737

38-
/**
39-
* @var PaymentHelper
40-
*/
41-
protected $paymentHelper;
42-
4338
/**
4439
* Payment method code
4540
*
@@ -70,8 +65,7 @@ public function __construct(
7065
$this->request = $request;
7166
$this->urlBuilder = $urlBuilder;
7267
$this->logger = $logger;
73-
$this->paymentHelper = $paymentHelper;
74-
$this->method = $this->paymentHelper->getMethodInstance($this->methodCode);
68+
$this->method = $paymentHelper->getMethodInstance($this->methodCode);
7569
}
7670

7771
/**

app/code/Magento/Quote/Test/Unit/Model/AddressDetailsManagementTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class AddressDetailsManagementTest extends \PHPUnit_Framework_TestCase
4444
*/
4545
protected $dataProcessor;
4646

47+
/** @var \Magento\Quote\Model\QuoteRepository|\PHPUnit_Framework_MockObject_MockObject */
48+
protected $quoteRepository;
49+
4750
/**
4851
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
4952
*/
@@ -58,6 +61,7 @@ protected function setUp()
5861
$this->shippingMethodManagement = $this->getMock('\Magento\Quote\Api\ShippingMethodManagementInterface');
5962
$this->addressDetailsFactory = $this->getMock('\Magento\Quote\Model\AddressDetailsFactory', [], [], '', false);
6063
$this->dataProcessor = $this->getMock('\Magento\Quote\Model\AddressAdditionalDataProcessor', [], [], '', false);
64+
$this->quoteRepository = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false);
6165

6266
$this->model = $this->objectManager->getObject(
6367
'Magento\Quote\Model\AddressDetailsManagement',
@@ -67,7 +71,8 @@ protected function setUp()
6771
'paymentMethodManagement' => $this->paymentMethodManagement,
6872
'shippingMethodManagement' => $this->shippingMethodManagement,
6973
'addressDetailsFactory' => $this->addressDetailsFactory,
70-
'dataProcessor' => $this->dataProcessor
74+
'dataProcessor' => $this->dataProcessor,
75+
'quoteRepository' => $this->quoteRepository,
7176
]
7277
);
7378
}
@@ -125,6 +130,16 @@ public function testSaveAddresses()
125130
->willReturnSelf();
126131
$this->dataProcessor->expects($this->once())->method('process')->with($additionalData);
127132

128-
$this->model->saveAddresses($cartId, $billingAddressMock, $shippingAddressMock, $additionalData);
133+
$quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false);
134+
$quote->expects($this->once())
135+
->method('setCheckoutMethod')
136+
->willReturnSelf();
137+
138+
$this->quoteRepository
139+
->expects($this->once())
140+
->method('getActive')
141+
->willReturn($quote);
142+
143+
$this->model->saveAddresses($cartId, $billingAddressMock, $shippingAddressMock, $additionalData, 'register');
129144
}
130145
}

app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ protected function setUp()
200200
'getBillingAddress',
201201
'setCustomerIsGuest',
202202
'setCustomerGroupId',
203-
'assignCustomer'
203+
'assignCustomer',
204+
'getPayment',
204205
],
205206
[],
206207
'',
@@ -724,6 +725,42 @@ public function testPlaceOrderIfCustomerIsGuest()
724725
$this->assertEquals($orderId, $service->placeOrder($cartId));
725726
}
726727

728+
/**
729+
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
730+
*/
731+
public function testPlaceOrderIfAgreementsIsNotValid()
732+
{
733+
$this->agreementsValidatorMock->expects($this->once())->method('isValid')->willReturn(false);
734+
735+
/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */
736+
$service = $this->getMock(
737+
'\Magento\Quote\Model\QuoteManagement',
738+
['submit'],
739+
[
740+
'eventManager' => $this->eventManager,
741+
'quoteValidator' => $this->quoteValidator,
742+
'orderFactory' => $this->orderFactory,
743+
'orderManagement' => $this->orderManagement,
744+
'customerManagement' => $this->customerManagement,
745+
'quoteAddressToOrder' => $this->quoteAddressToOrder,
746+
'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress,
747+
'quoteItemToOrderItem' => $this->quoteItemToOrderItem,
748+
'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment,
749+
'userContext' => $this->userContextMock,
750+
'quoteRepository' => $this->quoteRepositoryMock,
751+
'customerRepository' => $this->customerRepositoryMock,
752+
'customerModelFactory' => $this->customerFactoryMock,
753+
'dataObjectHelper' => $this->dataObjectHelperMock,
754+
'storeManager' => $this->storeManagerMock,
755+
'checkoutSession' => $this->checkoutSessionMock,
756+
'customerSession' => $this->customerSessionMock,
757+
'accountManagement' => $this->accountManagementMock,
758+
'agreementsValidator' => $this->agreementsValidatorMock,
759+
]
760+
);
761+
$service->placeOrder(45);
762+
}
763+
727764
public function testPlaceOrder()
728765
{
729766
$cartId = 323;
@@ -769,6 +806,15 @@ public function testPlaceOrder()
769806
->with($cartId)
770807
->willReturn($this->quoteMock);
771808

809+
$quotePayment = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false);
810+
$quotePayment->expects($this->once())
811+
->method('setQuote');
812+
$quotePayment->expects($this->once())
813+
->method('importData');
814+
$this->quoteMock->expects($this->atLeastOnce())
815+
->method('getPayment')
816+
->willReturn($quotePayment);
817+
772818
$this->quoteMock->expects($this->once())
773819
->method('getCheckoutMethod')
774820
->willReturn(\Magento\Checkout\Model\Type\Onepage::METHOD_CUSTOMER);
@@ -787,7 +833,12 @@ public function testPlaceOrder()
787833
$this->checkoutSessionMock->expects($this->once())->method('setLastOrderId')->with($orderId);
788834
$this->checkoutSessionMock->expects($this->once())->method('setLastRealOrderId')->with($orderIncrementId);
789835
$this->agreementsValidatorMock->expects($this->once())->method('isValid')->willReturn(true);
790-
$this->assertEquals($orderId, $service->placeOrder($cartId));
836+
837+
$paymentMethod = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false);
838+
$paymentMethod->expects($this->once())->method('setChecks');
839+
$paymentMethod->expects($this->once())->method('getData')->willReturn(['additional_data' => []]);
840+
841+
$this->assertEquals($orderId, $service->placeOrder($cartId, null, $paymentMethod));
791842
}
792843

793844
/**

0 commit comments

Comments
 (0)