Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IsProductSalableForRequestedQtyTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
12 
14 {
15  const API_PATH = '/V1/inventory/is-product-salable-for-requested-qty';
16  const SERVICE_NAME = 'inventorySalesApiIsProductSalableForRequestedQtyV1';
17 
21  public function executeDataProvider(): array
22  {
23  return [
24  ['SKU-1', 10, 1, true],
25  ['SKU-1', 20, 1, false],
26  ['SKU-1', 30, 1, true],
27  ];
28  }
29 
48  string $sku,
49  int $stockId,
50  float $requestedQty,
51  bool $expectedResult
52  ) {
53  $serviceInfo = [
54  'rest' => [
55  'resourcePath' => self::API_PATH . '/' . $sku . '/' . $stockId . '/' . $requestedQty,
56  'httpMethod' => Request::HTTP_METHOD_GET,
57  ],
58  'soap' => [
59  'service' => self::SERVICE_NAME,
60  'operation' => self::SERVICE_NAME . 'Execute',
61  ],
62  ];
63 
64  $res = (TESTS_WEB_API_ADAPTER === self::ADAPTER_REST)
65  ? $this->_webApiCall($serviceInfo)
66  : $this->_webApiCall($serviceInfo, [
67  'sku' => $sku,
68  'stockId' => $stockId,
69  'requestedQty' => $requestedQty
70  ]);
71 
72  self::assertEquals($expectedResult, $res['salable']);
73  }
74 }
testDeleteSourceItemConfiguration(string $sku, int $stockId, float $requestedQty, bool $expectedResult)
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)