@@ -29,6 +29,16 @@ class GuestCartManagementTest extends \PHPUnit_Framework_TestCase
29
29
*/
30
30
protected $ quoteIdMaskMock ;
31
31
32
+ /**
33
+ * @var \PHPUnit_Framework_MockObject_MockObject
34
+ */
35
+ protected $ cartRepositoryMock ;
36
+
37
+ /**
38
+ * @var \PHPUnit_Framework_MockObject_MockObject
39
+ */
40
+ protected $ quoteMock ;
41
+
32
42
/**
33
43
* @var \Magento\Quote\Model\GuestCart\GuestCartManagement
34
44
*/
@@ -62,11 +72,30 @@ protected function setUp()
62
72
false
63
73
);
64
74
75
+ $ this ->cartRepositoryMock = $ this ->getMock (
76
+ 'Magento\Quote\Api\CartRepositoryInterface ' ,
77
+ ['get ' , 'getList ' ],
78
+ [],
79
+ '' ,
80
+ false
81
+ );
82
+
83
+ $ this ->quoteMock = $ this ->getMockForAbstractClass (
84
+ 'Magento\Quote\Api\Data\CartInterface ' ,
85
+ [],
86
+ '' ,
87
+ false ,
88
+ true ,
89
+ true ,
90
+ ['setCheckoutMethod ' ]
91
+ );
92
+
65
93
$ this ->guestCartManagement = $ objectManager ->getObject (
66
94
'Magento\Quote\Model\GuestCart\GuestCartManagement ' ,
67
95
[
68
96
'quoteManagement ' => $ this ->quoteManagementMock ,
69
- 'quoteIdMaskFactory ' => $ this ->quoteIdMaskFactoryMock
97
+ 'quoteIdMaskFactory ' => $ this ->quoteIdMaskFactoryMock ,
98
+ 'cartRepository ' => $ this ->cartRepositoryMock
70
99
]
71
100
);
72
101
}
@@ -107,7 +136,9 @@ public function testPlaceOrder()
107
136
$ orderId = 1 ;
108
137
109
138
$ this ->quoteIdMaskMock ->expects ($ this ->once ())->method ('load ' )->with ($ cartId , 'masked_id ' )->willReturnSelf ();
110
- $ this ->quoteIdMaskMock ->expects ($ this ->once ())->method ('getQuoteId ' )->willReturn ($ maskedCartId );
139
+ $ this ->cartRepositoryMock ->expects ($ this ->once ())->method ('get ' )->willReturn ($ this ->quoteMock );
140
+ $ this ->quoteMock ->expects ($ this ->once ())->method ('setCheckoutMethod ' );
141
+ $ this ->quoteIdMaskMock ->expects ($ this ->any ())->method ('getQuoteId ' )->willReturn ($ maskedCartId );
111
142
$ this ->quoteIdMaskFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->quoteIdMaskMock );
112
143
$ this ->quoteManagementMock ->expects ($ this ->once ())->method ('placeOrder ' )->willReturn ($ orderId );
113
144
0 commit comments