6
6
*/
7
7
namespace Magento \Quote \Api ;
8
8
9
- use Magento \Catalog \Api \ProductRepositoryInterface ;
10
9
use Magento \Catalog \Model \CustomOptions \CustomOptionProcessor ;
11
10
use Magento \Framework \Webapi \Rest \Request ;
12
11
use Magento \Quote \Model \Quote ;
@@ -84,10 +83,9 @@ public function testGetList()
84
83
*/
85
84
public function testAddItem ()
86
85
{
87
- $ productSku = 'custom-design-simple-product ' ;
88
- $ productRepository = $ this ->objectManager ->create (ProductRepositoryInterface::class);
89
- $ product = $ productRepository ->get ($ productSku );
90
-
86
+ /** @var \Magento\Catalog\Model\Product $product */
87
+ $ product = $ this ->objectManager ->create (\Magento \Catalog \Model \Product::class)->load (2 );
88
+ $ productSku = $ product ->getSku ();
91
89
/** @var Quote $quote */
92
90
$ quote = $ this ->objectManager ->create (Quote::class);
93
91
$ quote ->load ('test_order_1 ' , 'reserved_order_id ' );
@@ -112,59 +110,10 @@ public function testAddItem()
112
110
],
113
111
];
114
112
$ this ->_webApiCall ($ serviceInfo , $ requestData );
115
- $ this ->assertTrue ($ quote ->hasProductId ($ product -> getId () ));
113
+ $ this ->assertTrue ($ quote ->hasProductId (2 ));
116
114
$ this ->assertEquals (7 , $ quote ->getItemByProduct ($ product )->getQty ());
117
115
}
118
116
119
- /**
120
- * @expectedException \Exception
121
- * @expectedExceptionCode 400
122
- * @dataProvider failedAddItemDataProvider
123
- * @param array|null $cartItem
124
- */
125
- public function testFailedAddItem (?array $ cartItem )
126
- {
127
- $ serviceInfo = [
128
- 'rest ' => [
129
- 'resourcePath ' => self ::RESOURCE_PATH . 'mine/items ' ,
130
- 'httpMethod ' => Request::HTTP_METHOD_POST ,
131
- ],
132
- 'soap ' => [
133
- 'service ' => self ::SERVICE_NAME ,
134
- 'serviceVersion ' => self ::SERVICE_VERSION ,
135
- 'operation ' => self ::SERVICE_NAME . 'Save ' ,
136
- ],
137
- ];
138
- $ requestData = [
139
- 'cartItem ' => $ cartItem ,
140
- ];
141
-
142
- $ this ->expectException (\Exception::class);
143
- $ this ->expectExceptionCode (TESTS_WEB_API_ADAPTER === self ::ADAPTER_SOAP ? 0 : 400 );
144
- $ this ->_webApiCall ($ serviceInfo , $ requestData );
145
- }
146
-
147
- /**
148
- * @return array
149
- */
150
- public function failedAddItemDataProvider (): array
151
- {
152
- return [
153
- 'absent cart item ' => [
154
- null ,
155
- ],
156
- 'empty cart item ' => [
157
- [],
158
- ],
159
- 'absent cart id ' => [
160
- [
161
- 'sku ' => 'custom-design-simple-product ' ,
162
- 'qty ' => 7 ,
163
- ],
164
- ],
165
- ];
166
- }
167
-
168
117
/**
169
118
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
170
119
*/
0 commit comments