7
7
8
8
namespace Magento \GraphQl \Quote \Customer ;
9
9
10
+ use Magento \GraphQl \Quote \GetMaskedQuoteIdByReservedOrderId ;
10
11
use Magento \Integration \Api \CustomerTokenServiceInterface ;
11
12
use Magento \OfflinePayments \Model \Checkmo ;
12
- use Magento \QuoteGraphQl \Model \GetMaskedQuoteIdByReversedQuoteId ;
13
13
use Magento \Quote \Model \QuoteFactory ;
14
14
use Magento \Quote \Model \QuoteIdToMaskedQuoteIdInterface ;
15
15
use Magento \Quote \Model \ResourceModel \Quote as QuoteResource ;
22
22
class SetPaymentMethodOnCartTest extends GraphQlAbstract
23
23
{
24
24
/**
25
- * @var CustomerTokenServiceInterface
25
+ * @var GetMaskedQuoteIdByReservedOrderId
26
26
*/
27
- private $ customerTokenService ;
27
+ private $ getMaskedQuoteIdByReservedOrderId ;
28
28
29
29
/**
30
- * @var GetMaskedQuoteIdByReversedQuoteId
30
+ * @var CustomerTokenServiceInterface
31
31
*/
32
- private $ getMaskedQuoteIdByReversedQuoteId ;
32
+ private $ customerTokenService ;
33
33
34
34
/**
35
35
* @var QuoteResource
@@ -52,7 +52,7 @@ class SetPaymentMethodOnCartTest extends GraphQlAbstract
52
52
protected function setUp ()
53
53
{
54
54
$ objectManager = Bootstrap::getObjectManager ();
55
- $ this ->getMaskedQuoteIdByReversedQuoteId = $ objectManager ->get (GetMaskedQuoteIdByReversedQuoteId ::class);
55
+ $ this ->getMaskedQuoteIdByReservedOrderId = $ objectManager ->get (GetMaskedQuoteIdByReservedOrderId ::class);
56
56
$ this ->quoteResource = $ objectManager ->get (QuoteResource::class);
57
57
$ this ->quoteFactory = $ objectManager ->get (QuoteFactory::class);
58
58
$ this ->quoteIdToMaskedId = $ objectManager ->get (QuoteIdToMaskedQuoteIdInterface::class);
@@ -61,13 +61,11 @@ protected function setUp()
61
61
62
62
/**
63
63
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
64
- * @throws \Exception
65
- * @throws \Magento\Framework\Exception\NoSuchEntityException
66
64
*/
67
65
public function testSetPaymentWithVirtualProduct ()
68
66
{
69
67
$ methodCode = Checkmo::PAYMENT_METHOD_CHECKMO_CODE ;
70
- $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ->execute ('test_order_with_virtual_product ' );
68
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_order_with_virtual_product ' );
71
69
72
70
$ query = $ this ->prepareMutationQuery ($ maskedQuoteId , $ methodCode );
73
71
$ response = $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
@@ -80,13 +78,11 @@ public function testSetPaymentWithVirtualProduct()
80
78
81
79
/**
82
80
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
83
- * @throws \Exception
84
- * @throws \Magento\Framework\Exception\NoSuchEntityException
85
81
*/
86
82
public function testSetPaymentWithSimpleProduct ()
87
83
{
88
84
$ methodCode = Checkmo::PAYMENT_METHOD_CHECKMO_CODE ;
89
- $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ->execute ('test_order_1 ' );
85
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_order_1 ' );
90
86
91
87
$ query = $ this ->prepareMutationQuery ($ maskedQuoteId , $ methodCode );
92
88
$ response = $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
@@ -120,7 +116,7 @@ public function testSetPaymentWithSimpleProductWithoutAddress()
120
116
public function testSetNonExistingPaymentMethod ()
121
117
{
122
118
$ methodCode = 'noway ' ;
123
- $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ->execute ('test_order_1 ' );
119
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_order_1 ' );
124
120
125
121
$ query = $ this ->prepareMutationQuery ($ maskedQuoteId , $ methodCode );
126
122
$ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
@@ -129,13 +125,13 @@ public function testSetNonExistingPaymentMethod()
129
125
/**
130
126
* @magentoApiDataFixture Magento/Customer/_files/customer.php
131
127
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
132
- * @throws \Exception
133
- * @throws \Magento\Framework\Exception\NoSuchEntityException
134
128
*/
135
129
public function testSetPaymentMethodToGuestCart ()
136
130
{
137
131
$ methodCode = Checkmo::PAYMENT_METHOD_CHECKMO_CODE ;
138
- $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ->execute ('test_order_with_simple_product_without_address ' );
132
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute (
133
+ 'test_order_with_simple_product_without_address '
134
+ );
139
135
140
136
$ query = $ this ->prepareMutationQuery ($ maskedQuoteId , $ methodCode );
141
137
@@ -149,13 +145,11 @@ public function testSetPaymentMethodToGuestCart()
149
145
/**
150
146
* @magentoApiDataFixture Magento/Customer/_files/three_customers.php
151
147
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
152
- * @throws \Exception
153
- * @throws \Magento\Framework\Exception\NoSuchEntityException
154
148
*/
155
149
public function testSetPaymentMethodToAnotherCustomerCart ()
156
150
{
157
151
$ methodCode = Checkmo::PAYMENT_METHOD_CHECKMO_CODE ;
158
- $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ->execute ('test_order_1 ' );
152
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_order_1 ' );
159
153
160
154
$ query = $ this ->prepareMutationQuery ($ maskedQuoteId , $ methodCode );
161
155
@@ -192,7 +186,7 @@ public function testPaymentMethodOnNonExistentCart()
192
186
public function testReSetPayment ()
193
187
{
194
188
/** @var \Magento\Quote\Model\Quote $quote */
195
- $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ('test_order_1_with_payment ' );
189
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId -> execute ('test_order_1_with_payment ' );
196
190
$ methodCode = Checkmo::PAYMENT_METHOD_CHECKMO_CODE ;
197
191
$ query = $ this ->prepareMutationQuery ($ maskedQuoteId , $ methodCode );
198
192
$ response = $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
@@ -231,16 +225,16 @@ private function prepareMutationQuery(
231
225
}
232
226
233
227
/**
234
- * @param string $reversedQuoteId
228
+ * @param string $reversedOrderId
235
229
* @param int $customerId
236
230
* @return string
237
231
*/
238
232
private function assignQuoteToCustomer (
239
- string $ reversedQuoteId ,
233
+ string $ reversedOrderId ,
240
234
int $ customerId
241
235
): string {
242
236
$ quote = $ this ->quoteFactory ->create ();
243
- $ this ->quoteResource ->load ($ quote , $ reversedQuoteId , 'reserved_order_id ' );
237
+ $ this ->quoteResource ->load ($ quote , $ reversedOrderId , 'reserved_order_id ' );
244
238
$ quote ->setCustomerId ($ customerId );
245
239
$ this ->quoteResource ->save ($ quote );
246
240
return $ this ->quoteIdToMaskedId ->execute ((int )$ quote ->getId ());
0 commit comments