Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-inventory-api
Test
Api
SourceItemRepository
GetListTest.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryApi\Test\Api\SourceItemRepository
;
9
10
use
Magento\Framework\Api\SearchCriteria
;
11
use
Magento\Framework\Api\SortOrder
;
12
use
Magento\Framework\Webapi\Rest\Request
;
13
use
Magento\InventoryApi\Api\Data\SourceItemInterface
;
14
use
Magento\TestFramework\Assert\AssertArrayContains
;
15
use
Magento\TestFramework\TestCase\WebapiAbstract
;
16
17
class
GetListTest
extends
WebapiAbstract
18
{
22
const
RESOURCE_PATH
=
'/V1/inventory/source-items'
;
23
const
SERVICE_NAME
=
'inventoryApiSourceItemRepositoryV1'
;
31
public
function
testGetList
()
32
{
33
$requestData
= [
34
'searchCriteria'
=> [
35
SearchCriteria::FILTER_GROUPS
=> [
36
[
37
'filters'
=> [
38
[
39
'field'
=>
SourceItemInterface::SKU
,
40
'value'
=>
'SKU-1'
,
41
'condition_type'
=>
'eq'
,
42
],
43
],
44
],
45
],
46
SearchCriteria::SORT_ORDERS
=> [
47
[
48
'field'
=>
SourceItemInterface::QUANTITY
,
49
'direction'
=>
SortOrder::SORT_DESC
,
50
],
51
],
52
SearchCriteria::CURRENT_PAGE
=> 2,
53
SearchCriteria::PAGE_SIZE
=> 2,
54
],
55
];
56
$expectedTotalCount = 4;
57
$expectedItemsData = [
58
[
59
SourceItemInterface::SOURCE_CODE
=>
'eu-1'
,
60
SourceItemInterface::SKU
=>
'SKU-1'
,
61
SourceItemInterface::QUANTITY
=> 5.5,
62
SourceItemInterface::STATUS
=>
SourceItemInterface::STATUS_IN_STOCK
,
63
],
64
[
65
SourceItemInterface::SOURCE_CODE
=>
'eu-2'
,
66
SourceItemInterface::SKU
=>
'SKU-1'
,
67
SourceItemInterface::QUANTITY
=> 3,
68
SourceItemInterface::STATUS
=>
SourceItemInterface::STATUS_IN_STOCK
,
69
],
70
];
71
72
$serviceInfo = [
73
'rest'
=> [
74
'resourcePath'
=> self::RESOURCE_PATH .
'?'
. http_build_query(
$requestData
),
75
'httpMethod'
=>
Request::HTTP_METHOD_GET
,
76
],
77
'soap'
=> [
78
'service'
=>
self::SERVICE_NAME
,
79
'operation'
=> self::SERVICE_NAME .
'GetList'
,
80
],
81
];
82
$response
= (TESTS_WEB_API_ADAPTER ===
self::ADAPTER_REST
)
83
? $this->
_webApiCall
($serviceInfo)
84
: $this->
_webApiCall
($serviceInfo,
$requestData
);
85
86
AssertArrayContains::assert
(
$requestData
[
'searchCriteria'
],
$response
[
'search_criteria'
]);
87
self::assertEquals($expectedTotalCount,
$response
[
'total_count'
]);
88
AssertArrayContains::assert
($expectedItemsData,
$response
[
'items'
]);
89
}
90
}
Magento\InventoryApi\Api\Data\SourceItemInterface\QUANTITY
const QUANTITY
Definition:
SourceItemInterface.php:27
Magento\Framework\Api\SearchCriteria\SORT_ORDERS
const SORT_ORDERS
Definition:
SearchCriteria.php:19
$response
$response
Definition:
404.php:11
Magento\InventoryApi\Test\Api\SourceItemRepository
Definition:
GetListTest.php:8
$requestData
$requestData
Definition:
order_configurable_product.php:31
Magento\InventoryApi\Api\Data\SourceItemInterface\STATUS
const STATUS
Definition:
SourceItemInterface.php:28
Magento\TestFramework\TestCase\WebapiAbstract\_webApiCall
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
Definition:
WebapiAbstract.php:165
Magento\InventoryApi\Test\Api\SourceItemRepository\GetListTest\testGetList
testGetList()
Definition:
GetListTest.php:31
Magento\InventoryApi\Api\Data\SourceItemInterface\SOURCE_CODE
const SOURCE_CODE
Definition:
SourceItemInterface.php:26
Magento\InventoryApi\Api\Data\SourceItemInterface\STATUS_IN_STOCK
const STATUS_IN_STOCK
Definition:
SourceItemInterface.php:35
Magento\InventoryApi\Api\Data\SourceItemInterface
Definition:
SourceItemInterface.php:20
Magento\InventoryApi\Test\Api\SourceItemRepository\GetListTest\SERVICE_NAME
const SERVICE_NAME
Definition:
GetListTest.php:23
Magento\Framework\Api\SearchCriteria
Magento\Framework\Webapi\Rest\Request\HTTP_METHOD_GET
const HTTP_METHOD_GET
Definition:
Request.php:19
Magento\InventoryApi\Test\Api\SourceItemRepository\GetListTest\RESOURCE_PATH
const RESOURCE_PATH
Definition:
GetListTest.php:22
Magento\Framework\Api\SearchCriteria\CURRENT_PAGE
const CURRENT_PAGE
Definition:
SearchCriteria.php:21
Magento\InventoryApi\Api\Data\SourceItemInterface\SKU
const SKU
Definition:
SourceItemInterface.php:25
Magento\Framework\Api\SortOrder\SORT_DESC
const SORT_DESC
Definition:
SortOrder.php:22
Magento\InventoryApi\Test\Api\SourceItemRepository\GetListTest
Definition:
GetListTest.php:17
Magento\TestFramework\Assert\AssertArrayContains
Definition:
AssertArrayContains.php:14
Magento\Framework\Webapi\Rest\Request
Magento\TestFramework\TestCase\WebapiAbstract
Definition:
WebapiAbstract.php:19
Magento\Framework\Api\SortOrder
Definition:
SortOrder.php:17
Magento\TestFramework\TestCase\WebapiAbstract\ADAPTER_REST
const ADAPTER_REST
Definition:
WebapiAbstract.php:34
Magento\Framework\Api\SearchCriteria\FILTER_GROUPS
const FILTER_GROUPS
Definition:
SearchCriteria.php:18
Magento\Framework\Api\SearchCriteria\PAGE_SIZE
const PAGE_SIZE
Definition:
SearchCriteria.php:20
Magento\TestFramework\Assert\AssertArrayContains\assert
static assert(array $expected, array $actual)
Definition:
AssertArrayContains.php:21