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/sources';
23  const SERVICE_NAME = 'inventoryApiSourceRepositoryV1';
29  public function testGetList()
30  {
31  $requestData = [
32  'searchCriteria' => [
34  [
35  'filters' => [
36  [
37  'field' => SourceInterface::ENABLED,
38  'value' => 1,
39  'condition_type' => 'eq',
40  ],
41  ],
42  ],
43  ],
45  [
46  'field' => SourceInterface::NAME,
47  'direction' => SortOrder::SORT_DESC,
48  ],
49  ],
52  ],
53  ];
54  $expectedTotalCount = 4;
55  $expectedItemsData = [
56  [
58  SourceInterface::NAME => 'EU-source-2',
59  ],
60  [
62  SourceInterface::NAME => 'EU-source-1',
63  ],
64  ];
65 
66  $serviceInfo = [
67  'rest' => [
68  'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData),
69  'httpMethod' => Request::HTTP_METHOD_GET,
70  ],
71  'soap' => [
72  'service' => self::SERVICE_NAME,
73  'operation' => self::SERVICE_NAME . 'GetList',
74  ],
75  ];
76  $response = (TESTS_WEB_API_ADAPTER == self::ADAPTER_REST)
77  ? $this->_webApiCall($serviceInfo)
78  : $this->_webApiCall($serviceInfo, $requestData);
79 
80  AssertArrayContains::assert($requestData['searchCriteria'], $response['search_criteria']);
81  self::assertGreaterThanOrEqual($expectedTotalCount, $response['total_count']);
82  AssertArrayContains::assert($expectedItemsData, $response['items']);
83  }
84 }
$response
Definition: 404.php:11
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
static assert(array $expected, array $actual)