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
magento2-base
dev
tests
api-functional
testsuite
Magento
GroupedProduct
Api
ProductLinkRepositoryTest.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\GroupedProduct\Api
;
8
9
use
Magento\TestFramework\Helper\Bootstrap
;
10
11
class
ProductLinkRepositoryTest
extends
\Magento\TestFramework\TestCase\WebapiAbstract
12
{
13
const
SERVICE_NAME
=
'catalogProductLinkRepositoryV1'
;
14
const
SERVICE_VERSION
=
'V1'
;
15
const
RESOURCE_PATH
=
'/V1/products/'
;
16
20
protected
$objectManager
;
21
22
protected
function
setUp
()
23
{
24
$this->objectManager =
Bootstrap::getObjectManager
();
25
}
26
31
public
function
testSave()
32
{
33
$productSku =
'grouped-product'
;
34
$linkType =
'associated'
;
35
$productData
= [
36
'sku'
=> $productSku,
37
'link_type'
=> $linkType,
38
'linked_product_type'
=>
'simple'
,
39
'linked_product_sku'
=>
'simple-1'
,
40
'position'
=> 3,
41
'extension_attributes'
=> [
42
'qty'
=> (float) 300.0000,
43
],
44
];
45
46
$serviceInfo = [
47
'rest'
=> [
48
'resourcePath'
=> self::RESOURCE_PATH . $productSku .
'/links'
,
49
'httpMethod'
=>
\Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT
,
50
],
51
'soap'
=> [
52
'service'
=>
self::SERVICE_NAME
,
53
'serviceVersion'
=>
self::SERVICE_VERSION
,
54
'operation'
=> self::SERVICE_NAME .
'Save'
,
55
],
56
];
57
$this->
_webApiCall
($serviceInfo, [
'entity'
=>
$productData
]);
58
60
$linkManagement
= $this->objectManager->get(\
Magento
\Catalog\Api\ProductLinkManagementInterface::class);
61
$actual =
$linkManagement
->getLinkedItemsByType($productSku, $linkType);
62
array_walk($actual,
function
(&
$item
) {
63
$item
=
$item
->__toArray();
64
});
65
$this->assertEquals(
$productData
, $actual[2]);
66
}
67
}
Magento\TestFramework\Helper\Bootstrap
Definition:
Bootstrap.php:12
Magento\TestFramework\TestCase\WebapiAbstract\_webApiCall
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
Definition:
WebapiAbstract.php:165
Magento\GroupedProduct\Api\ProductLinkRepositoryTest\setUp
setUp()
Definition:
ProductLinkRepositoryTest.php:22
Magento\GroupedProduct\Api\ProductLinkRepositoryTest
Definition:
ProductLinkRepositoryTest.php:11
Magento\GroupedProduct\Api\ProductLinkRepositoryTest\SERVICE_VERSION
const SERVICE_VERSION
Definition:
ProductLinkRepositoryTest.php:14
$item
$item
Definition:
partial_invoice.php:27
Magento\Framework\Webapi\Rest\Request\HTTP_METHOD_PUT
const HTTP_METHOD_PUT
Definition:
Request.php:21
Magento\GroupedProduct\Api\ProductLinkRepositoryTest\RESOURCE_PATH
const RESOURCE_PATH
Definition:
ProductLinkRepositoryTest.php:15
Magento\GroupedProduct\Api\ProductLinkRepositoryTest\$objectManager
$objectManager
Definition:
ProductLinkRepositoryTest.php:20
$linkManagement
$linkManagement
Definition:
product_with_category.php:81
Magento
$productData
$productData
Definition:
products_virtual.php:38
Magento\GroupedProduct\Api\ProductLinkRepositoryTest\SERVICE_NAME
const SERVICE_NAME
Definition:
ProductLinkRepositoryTest.php:13
Magento\GroupedProduct\Api
Definition:
ProductLinkManagementTest.php:7
Magento\TestFramework\TestCase\WebapiAbstract
Definition:
WebapiAbstract.php:19
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125