Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GetListTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
16 
18 {
22  const RESOURCE_PATH = '/V1/inventory/stocks';
23  const SERVICE_NAME = 'inventoryApiStockRepositoryV1';
33  public function testGetList(array $searchCriteria, int $expectedTotalCount, array $expectedItemsData)
34  {
35  $requestData = ['searchCriteria' => $searchCriteria];
36  $serviceInfo = [
37  'rest' => [
38  'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData),
39  'httpMethod' => Request::HTTP_METHOD_GET,
40  ],
41  'soap' => [
42  'service' => self::SERVICE_NAME,
43  'operation' => self::SERVICE_NAME . 'GetList',
44  ],
45  ];
46  $response = (TESTS_WEB_API_ADAPTER === self::ADAPTER_REST)
47  ? $this->_webApiCall($serviceInfo)
48  : $this->_webApiCall($serviceInfo, $requestData);
49 
51  self::assertGreaterThanOrEqual($expectedTotalCount, $response['total_count']);
52  AssertArrayContains::assert($expectedItemsData, $response['items']);
53  }
54 
58  public function dataProviderGetList(): array
59  {
60  return [
61  'filtering' => [
62  [
64  [
65  'filters' => [
66  [
67  'field' => StockInterface::NAME,
68  'value' => 'EU-stock',
69  'condition_type' => 'eq',
70  ],
71  ],
72  ],
73  ],
74  ],
75  1,
76  [
77  [
78  StockInterface::NAME => 'EU-stock',
79  ],
80  ],
81  ],
82  'ordering_paging' => [
83  [
84  SearchCriteria::FILTER_GROUPS => [], // It is need for soap mode
86  [
87  'field' => StockInterface::NAME,
88  'direction' => SortOrder::SORT_DESC,
89  ],
90  ],
93  ],
94  3,
95  [
96  [
97  StockInterface::NAME => 'EU-stock',
98  ],
99  ],
100  ],
101  ];
102  }
103 }
$response
Definition: 404.php:11
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$searchCriteria
testGetList(array $searchCriteria, int $expectedTotalCount, array $expectedItemsData)
Definition: GetListTest.php:33
static assert(array $expected, array $actual)