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
SourceRepository
GetListTest.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryApi\Test\Api\SourceRepository
;
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\SourceInterface
;
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/sources'
;
23
const
SERVICE_NAME
=
'inventoryApiSourceRepositoryV1'
;
29
public
function
testGetList
()
30
{
31
$requestData
= [
32
'searchCriteria'
=> [
33
SearchCriteria::FILTER_GROUPS
=> [
34
[
35
'filters'
=> [
36
[
37
'field'
=>
SourceInterface::ENABLED
,
38
'value'
=> 1,
39
'condition_type'
=>
'eq'
,
40
],
41
],
42
],
43
],
44
SearchCriteria::SORT_ORDERS
=> [
45
[
46
'field'
=>
SourceInterface::NAME
,
47
'direction'
=>
SortOrder::SORT_DESC
,
48
],
49
],
50
SearchCriteria::CURRENT_PAGE
=> 2,
51
SearchCriteria::PAGE_SIZE
=> 2,
52
],
53
];
54
$expectedTotalCount = 4;
55
$expectedItemsData = [
56
[
57
SourceInterface::ENABLED
=>
true
,
58
SourceInterface::NAME
=>
'EU-source-2'
,
59
],
60
[
61
SourceInterface::ENABLED
=>
true
,
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
}
Magento\Framework\Api\SearchCriteria\SORT_ORDERS
const SORT_ORDERS
Definition:
SearchCriteria.php:19
Magento\InventoryApi\Test\Api\SourceRepository\GetListTest
Definition:
GetListTest.php:17
$response
$response
Definition:
404.php:11
Magento\InventoryApi\Test\Api\SourceRepository
Definition:
CarrierLinkManagementTest.php:8
$requestData
$requestData
Definition:
order_configurable_product.php:31
Magento\TestFramework\TestCase\WebapiAbstract\_webApiCall
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
Definition:
WebapiAbstract.php:165
Magento\Framework\Api\SearchCriteria
Magento\Framework\Webapi\Rest\Request\HTTP_METHOD_GET
const HTTP_METHOD_GET
Definition:
Request.php:19
Magento\Framework\Api\SearchCriteria\CURRENT_PAGE
const CURRENT_PAGE
Definition:
SearchCriteria.php:21
Magento\Framework\Api\SortOrder\SORT_DESC
const SORT_DESC
Definition:
SortOrder.php:22
Magento\InventoryApi\Api\Data\SourceInterface
Definition:
SourceInterface.php:17
Magento\TestFramework\Assert\AssertArrayContains
Definition:
AssertArrayContains.php:14
Magento\InventoryApi\Api\Data\SourceInterface\ENABLED
const ENABLED
Definition:
SourceInterface.php:26
Magento\Framework\Webapi\Rest\Request
Magento\TestFramework\TestCase\WebapiAbstract
Definition:
WebapiAbstract.php:19
Magento\InventoryApi\Test\Api\SourceRepository\GetListTest\testGetList
testGetList()
Definition:
GetListTest.php:29
Magento\Framework\Api\SortOrder
Definition:
SortOrder.php:17
Magento\InventoryApi\Test\Api\SourceRepository\GetListTest\RESOURCE_PATH
const RESOURCE_PATH
Definition:
GetListTest.php:22
Magento\TestFramework\TestCase\WebapiAbstract\ADAPTER_REST
const ADAPTER_REST
Definition:
WebapiAbstract.php:34
Magento\InventoryApi\Api\Data\SourceInterface\NAME
const NAME
Definition:
SourceInterface.php:23
Magento\InventoryApi\Test\Api\SourceRepository\GetListTest\SERVICE_NAME
const SERVICE_NAME
Definition:
GetListTest.php:23
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