Skip to content

Commit 475c609

Browse files
author
Dmytro Voskoboinikov
committed
MAGETWO-38779: Stabilize story
1 parent 859d93f commit 475c609

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
2121
*/
2222
protected $orderConfig;
2323

24-
/**
25-
* @var \Magento\Sales\Model\OrderFactory | \PHPUnit_Framework_MockObject_MockObject
26-
*/
27-
protected $orderFactory;
28-
2924
/**
3025
* @var \Magento\Checkout\Model\Session | \PHPUnit_Framework_MockObject_MockObject
3126
*/
@@ -36,14 +31,19 @@ protected function setUp()
3631
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
3732

3833
$this->orderConfig = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false);
39-
$this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false);
40-
$this->checkoutSession = $this->getMock('Magento\Checkout\Model\Session', ['getLastOrderId'], [], '', false);
34+
35+
$this->checkoutSession = $this->getMock(
36+
'Magento\Checkout\Model\Session',
37+
['getLastOrderId', 'getLastRealOrderId', 'getLastOrderStatus'],
38+
[],
39+
'',
40+
false
41+
);
4142

4243
$this->block = $objectManager->getObject(
4344
'Magento\Checkout\Block\Onepage\Success',
4445
[
4546
'orderConfig' => $this->orderConfig,
46-
'orderFactory' => $this->orderFactory,
4747
'checkoutSession' => $this->checkoutSession
4848
]
4949
);
@@ -74,28 +74,21 @@ public function testGetAdditionalInfoHtml()
7474
public function testToHtmlOrderVisibleOnFront(array $invisibleStatuses, $orderStatus, $expectedResult)
7575
{
7676
$orderId = 5;
77-
$order = $this->getMock('Magento\Sales\Model\Order', ['getId', '__wakeup', 'load', 'getStatus'], [], '', false);
78-
79-
$order->expects($this->any())
80-
->method('load')
81-
->with($orderId)
82-
->will($this->returnValue($order));
83-
$order->expects($this->any())
84-
->method('getId')
85-
->will($this->returnValue($orderId));
86-
$order->expects($this->any())
87-
->method('getStatus')
88-
->will($this->returnValue($orderStatus));
77+
$realOrderId = 100003332;
8978

9079
$this->checkoutSession->expects($this->once())
9180
->method('getLastOrderId')
9281
->will($this->returnValue($orderId));
82+
$this->checkoutSession->expects($this->once())
83+
->method('getLastRealOrderId')
84+
->will($this->returnValue($realOrderId));
85+
$this->checkoutSession->expects($this->once())
86+
->method('getLastOrderStatus')
87+
->will($this->returnValue($orderStatus));
88+
9389
$this->orderConfig->expects($this->any())
9490
->method('getInvisibleOnFrontStatuses')
9591
->will($this->returnValue($invisibleStatuses));
96-
$this->orderFactory->expects($this->once())
97-
->method('create')
98-
->will($this->returnValue($order));
9992

10093
$this->block->toHtml();
10194

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ protected function setUp()
211211
$this->dataObjectHelperMock = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false);
212212
$this->checkoutSessionMock = $this->getMock(
213213
'Magento\Checkout\Model\Session',
214-
['setLastQuoteId', 'setLastSuccessQuoteId', 'setLastOrderId', 'setLastRealOrderId'],
214+
['setLastQuoteId', 'setLastSuccessQuoteId', 'setLastOrderId', 'setLastRealOrderId', 'setLastOrderStatus'],
215215
[],
216216
'',
217217
false
@@ -652,6 +652,7 @@ public function testPlaceOrderIfCustomerIsGuest()
652652
$cartId = 100;
653653
$orderId = 332;
654654
$orderIncrementId = 100003332;
655+
$orderStatus = 'status1';
655656
$email = 'email@mail.com';
656657

657658
$this->quoteRepositoryMock->expects($this->once())
@@ -710,13 +711,17 @@ public function testPlaceOrderIfCustomerIsGuest()
710711
$service->expects($this->once())->method('submit')->willReturn($orderMock);
711712

712713
$this->quoteMock->expects($this->atLeastOnce())->method('getId')->willReturn($cartId);
714+
713715
$orderMock->expects($this->atLeastOnce())->method('getId')->willReturn($orderId);
714716
$orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($orderIncrementId);
717+
$orderMock->expects($this->atLeastOnce())->method('getStatus')->willReturn($orderStatus);
715718

716719
$this->checkoutSessionMock->expects($this->once())->method('setLastQuoteId')->with($cartId);
717720
$this->checkoutSessionMock->expects($this->once())->method('setLastSuccessQuoteId')->with($cartId);
718721
$this->checkoutSessionMock->expects($this->once())->method('setLastOrderId')->with($orderId);
719722
$this->checkoutSessionMock->expects($this->once())->method('setLastRealOrderId')->with($orderIncrementId);
723+
$this->checkoutSessionMock->expects($this->once())->method('setLastOrderStatus')->with($orderStatus);
724+
720725
$this->agreementsValidatorMock->expects($this->once())->method('isValid')->willReturn(true);
721726

722727
$this->assertEquals($orderId, $service->placeOrder($cartId));
@@ -763,6 +768,7 @@ public function testPlaceOrder()
763768
$cartId = 323;
764769
$orderId = 332;
765770
$orderIncrementId = 100003332;
771+
$orderStatus = 'status1';
766772

767773
/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */
768774
$service = $this->getMock(
@@ -822,13 +828,17 @@ public function testPlaceOrder()
822828
$service->expects($this->once())->method('submit')->willReturn($orderMock);
823829

824830
$this->quoteMock->expects($this->atLeastOnce())->method('getId')->willReturn($cartId);
831+
825832
$orderMock->expects($this->atLeastOnce())->method('getId')->willReturn($orderId);
826833
$orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($orderIncrementId);
834+
$orderMock->expects($this->atLeastOnce())->method('getStatus')->willReturn($orderStatus);
827835

828836
$this->checkoutSessionMock->expects($this->once())->method('setLastQuoteId')->with($cartId);
829837
$this->checkoutSessionMock->expects($this->once())->method('setLastSuccessQuoteId')->with($cartId);
830838
$this->checkoutSessionMock->expects($this->once())->method('setLastOrderId')->with($orderId);
831839
$this->checkoutSessionMock->expects($this->once())->method('setLastRealOrderId')->with($orderIncrementId);
840+
$this->checkoutSessionMock->expects($this->once())->method('setLastOrderStatus')->with($orderStatus);
841+
832842
$this->agreementsValidatorMock->expects($this->once())->method('isValid')->willReturn(true);
833843

834844
$paymentMethod = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false);

0 commit comments

Comments
 (0)