|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * |
4 | 3 | * Copyright © Magento, Inc. All rights reserved. |
5 | 4 | * See COPYING.txt for license details. |
6 | 5 | */ |
7 | 6 | namespace Magento\Quote\Api; |
8 | 7 |
|
9 | 8 | use Magento\CatalogInventory\Api\StockRegistryInterface; |
10 | 9 | use Magento\CatalogInventory\Model\Stock; |
| 10 | +use Magento\TestFramework\Helper\Bootstrap; |
| 11 | +use Magento\TestFramework\ObjectManager; |
11 | 12 | use Magento\TestFramework\TestCase\WebapiAbstract; |
12 | 13 |
|
| 14 | +/** |
| 15 | + * Test for Magento\Quote\Api\GuestCartItemRepositoryInterface. |
| 16 | + */ |
13 | 17 | class GuestCartItemRepositoryTest extends WebapiAbstract |
14 | 18 | { |
15 | | - const SERVICE_VERSION = 'V1'; |
16 | | - const SERVICE_NAME = 'quoteGuestCartItemRepositoryV1'; |
17 | | - const RESOURCE_PATH = '/V1/guest-carts/'; |
| 19 | + public const SERVICE_NAME = 'quoteGuestCartItemRepositoryV1'; |
| 20 | + private const SERVICE_VERSION = 'V1'; |
| 21 | + private const RESOURCE_PATH = '/V1/guest-carts/'; |
18 | 22 |
|
19 | 23 | /** |
20 | | - * @var \Magento\TestFramework\ObjectManager |
| 24 | + * @var ObjectManager |
21 | 25 | */ |
22 | | - protected $objectManager; |
| 26 | + private $objectManager; |
23 | 27 |
|
| 28 | + /** |
| 29 | + * @inheritdoc |
| 30 | + */ |
24 | 31 | protected function setUp() |
25 | 32 | { |
26 | | - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
| 33 | + $this->objectManager = Bootstrap::getObjectManager(); |
27 | 34 | } |
28 | 35 |
|
29 | 36 | /** |
| 37 | + * Test quote items |
| 38 | + * |
30 | 39 | * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php |
31 | 40 | */ |
32 | 41 | public function testGetList() |
@@ -112,12 +121,16 @@ public function testAddItem() |
112 | 121 | ]; |
113 | 122 |
|
114 | 123 | $requestData = [ |
115 | | - "cartItem" => [ |
116 | | - "sku" => $productSku, |
117 | | - "qty" => 7, |
118 | | - "quote_id" => $cartId, |
| 124 | + 'cartItem' => [ |
| 125 | + 'sku' => $productSku, |
| 126 | + 'qty' => 7, |
119 | 127 | ], |
120 | 128 | ]; |
| 129 | + |
| 130 | + if (TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP) { |
| 131 | + $requestData['cartItem']['quote_id'] = $cartId; |
| 132 | + } |
| 133 | + |
121 | 134 | $this->_webApiCall($serviceInfo, $requestData); |
122 | 135 | $this->assertTrue($quote->hasProductId(2)); |
123 | 136 | $this->assertEquals(7, $quote->getItemByProduct($product)->getQty()); |
@@ -205,20 +218,11 @@ public function testUpdateItem(array $stockData, string $errorMessage = null) |
205 | 218 | ], |
206 | 219 | ]; |
207 | 220 |
|
208 | | - if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { |
209 | | - $requestData = [ |
210 | | - "cartItem" => [ |
211 | | - "qty" => 5, |
212 | | - "quote_id" => $cartId, |
213 | | - "itemId" => $itemId, |
214 | | - ], |
215 | | - ]; |
216 | | - } else { |
217 | | - $requestData = [ |
218 | | - "cartItem" => [ |
219 | | - "qty" => 5, |
220 | | - "quote_id" => $cartId, |
221 | | - ], |
| 221 | + $requestData['cartItem']['qty'] = 5; |
| 222 | + if (TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP) { |
| 223 | + $requestData['cartItem'] += [ |
| 224 | + 'quote_id' => $cartId, |
| 225 | + 'itemId' => $itemId, |
222 | 226 | ]; |
223 | 227 | } |
224 | 228 | if ($errorMessage) { |
|
0 commit comments