29 public function testAddItem()
32 $product = $this->objectManager->create(\
Magento\Catalog\Model\Product::class)->load(1);
36 $quote->load(
'reserved_order_id',
'reserved_order_id');
40 'resourcePath' =>
'/V1/carts/' .
$cartId .
'/items',
46 'operation' => self::SERVICE_NAME .
'Save',
51 $linkId = array_values(
$product->getDownloadableLinks())[0]->getId();
59 'extension_attributes' => [
60 'downloadable_option' => [
61 'downloadable_links' => [$linkId]
69 $this->assertEquals(
'downloadable-product',
$response[
'sku']);
73 $response[
'product_option'][
'extension_attributes'][
'downloadable_option'][
'downloadable_links']
75 $this->assertContains(
77 $response[
'product_option'][
'extension_attributes'][
'downloadable_option'][
'downloadable_links']
86 public function testAddItemWithInvalidLinkId()
89 $product = $this->objectManager->create(\
Magento\Catalog\Model\Product::class)->load(1);
91 $quote = $this->objectManager->create(\
Magento\Quote\Model\Quote::class);
92 $quote->load(
'reserved_order_id',
'reserved_order_id');
97 'resourcePath' =>
'/V1/carts/' .
$cartId .
'/items',
103 'operation' => self::SERVICE_NAME .
'Save',
111 'sku' => $productSku,
114 'product_option' => [
115 'extension_attributes' => [
116 'downloadable_option' => [
117 'downloadable_links' => [$linkId]
129 public function testUpdateItem()
132 $quote = $this->objectManager->create(\
Magento\Quote\Model\Quote::class);
133 $quote->load(
'reserved_order_id_1',
'reserved_order_id');
135 $product = $this->objectManager->create(\
Magento\Catalog\Model\Product::class);
138 $itemId =
$quote->getAllItems()[0]->getId();
141 'resourcePath' =>
'/V1/carts/' .
$cartId .
'/items/' . $itemId,
147 'operation' => self::SERVICE_NAME .
'Save',
152 $linkId = array_values(
$product->getDownloadableLinks())[0]->getId();
158 'item_id' => $itemId,
159 'sku' =>
'downloadable-product',
160 'product_option' => [
161 'extension_attributes' => [
162 'downloadable_option' => [
163 'downloadable_links' => [$linkId]
171 $this->assertEquals(
'downloadable-product',
$response[
'sku']);
172 $this->assertEquals(2,
$response[
'qty']);
175 $response[
'product_option'][
'extension_attributes'][
'downloadable_option'][
'downloadable_links']
177 $this->assertContains(
179 $response[
'product_option'][
'extension_attributes'][
'downloadable_option'][
'downloadable_links']
187 public function testUpdateItemWithInvalidLinkId()
190 $quote = $this->objectManager->create(\
Magento\Quote\Model\Quote::class);
191 $quote->load(
'reserved_order_id_1',
'reserved_order_id');
193 $product = $this->objectManager->create(\
Magento\Catalog\Model\Product::class);
196 $itemId =
$quote->getAllItems()[0]->getId();
201 'operation' => self::SERVICE_NAME .
'Save',
204 'resourcePath' =>
'/V1/carts/' .
$cartId .
'/items/' . $itemId,
215 'item_id' => $itemId,
216 'sku' =>
'downloadable-product',
217 'product_option' => [
218 'extension_attributes' => [
219 'downloadable_option' => [
220 'downloadable_links' => [$linkId]
232 public function testGetList()
235 $quote = $this->objectManager->create(\
Magento\Quote\Model\Quote::class);
236 $quote->load(
'reserved_order_id_1',
'reserved_order_id');
238 $product = $this->objectManager->create(\
Magento\Catalog\Model\Product::class);
241 $linkId = array_values(
$product->getDownloadableLinks())[0]->getId();
246 'item_id' =>
$item->getItemId(),
247 'sku' =>
$item->getSku(),
248 'name' =>
$item->getName(),
249 'price' =>
$item->getPrice(),
250 'qty' =>
$item->getQty(),
251 'product_type' =>
$item->getProductType(),
252 'quote_id' =>
$item->getQuoteId(),
253 'product_option' => [
254 'extension_attributes' => [
255 'downloadable_option' => [
256 'downloadable_links' => [$linkId]
264 'resourcePath' =>
'/V1/carts/' .
$cartId .
'/items',
270 'operation' => self::SERVICE_NAME .
'GetList',
281 public function testUpdateItemQty()
284 $quote = $this->objectManager->create(\
Magento\Quote\Model\Quote::class);
285 $quote->load(
'reserved_order_id_1',
'reserved_order_id');
286 $product = $this->objectManager->create(\
Magento\Catalog\Model\Product::class);
290 $itemId =
$quote->getAllItems()[0]->getId();
293 'resourcePath' =>
'/V1/carts/' .
$cartId .
'/items/' . $itemId,
299 'operation' => self::SERVICE_NAME .
'Save',
304 $linkId = array_values(
$product->getDownloadableLinks())[0]->getId();
310 'item_id' => $itemId,
311 'sku' =>
'downloadable-product',
316 $this->assertEquals(
'downloadable-product',
$response[
'sku']);
317 $this->assertEquals(2,
$response[
'qty']);
320 $response[
'product_option'][
'extension_attributes'][
'downloadable_option'][
'downloadable_links']
322 $this->assertContains(
324 $response[
'product_option'][
'extension_attributes'][
'downloadable_option'][
'downloadable_links']
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
static getObjectManager()