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
Sales
Service
V1
ShipmentAddTrackTest.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Sales\Service\V1
;
7
8
use
Magento\Framework\Webapi\Rest\Request
;
9
use
Magento\Sales\Api\Data\ShipmentTrackInterface
;
10
use
Magento\Sales\Model\Order\Shipment\Track
;
11
use
Magento\Sales\Model\ResourceModel\Order\Shipment\Collection
;
12
use
Magento\TestFramework\Helper\Bootstrap
;
13
use
Magento\TestFramework\TestCase\WebapiAbstract
;
14
18
class
ShipmentAddTrackTest
extends
WebapiAbstract
19
{
23
const
SERVICE_READ_NAME
=
'salesShipmentTrackRepositoryV1'
;
24
28
const
SERVICE_VERSION
=
'V1'
;
29
33
const
SHIPMENT_INCREMENT_ID
=
'100000001'
;
34
38
private
$objectManager;
39
43
protected
function
setUp
()
44
{
45
$this->objectManager =
Bootstrap::getObjectManager
();
46
}
47
53
public
function
testShipmentAddTrack()
54
{
55
$shipmentCollection = $this->objectManager->get(Collection::class);
57
$shipment
= $shipmentCollection->getFirstItem();
58
59
$trackData = [
60
ShipmentTrackInterface::ENTITY_ID
=>
null
,
61
ShipmentTrackInterface::ORDER_ID
=>
$shipment
->getOrderId(),
62
ShipmentTrackInterface::PARENT_ID
=>
$shipment
->getId(),
63
ShipmentTrackInterface::WEIGHT
=> 20,
64
ShipmentTrackInterface::QTY
=> 5,
65
ShipmentTrackInterface::TRACK_NUMBER
=> 2,
66
ShipmentTrackInterface::DESCRIPTION
=>
'Shipment description'
,
67
ShipmentTrackInterface::TITLE
=>
'Shipment title'
,
68
ShipmentTrackInterface::CARRIER_CODE
=>
Track::CUSTOM_CARRIER_CODE
,
69
];
70
71
$result
= $this->
_webApiCall
($this->getServiceInfo(), [
'entity'
=> $trackData]);
72
73
self::assertNotEmpty(
$result
);
74
self::assertNotEmpty(
$result
[
ShipmentTrackInterface::ENTITY_ID
]);
75
self::assertEquals(
$shipment
->getId(),
$result
[
ShipmentTrackInterface::PARENT_ID
]);
76
}
82
private
function
getServiceInfo()
83
{
84
return
[
85
'rest'
=> [
86
'resourcePath'
=>
'/V1/shipment/track'
,
87
'httpMethod'
=>
Request::HTTP_METHOD_POST
,
88
],
89
'soap'
=> [
90
'service'
=>
self::SERVICE_READ_NAME
,
91
'serviceVersion'
=>
self::SERVICE_VERSION
,
92
'operation'
=> self::SERVICE_READ_NAME .
'save'
,
93
],
94
];
95
}
96
}
Magento\Sales\Service\V1\ShipmentAddTrackTest\SERVICE_VERSION
const SERVICE_VERSION
Definition:
ShipmentAddTrackTest.php:28
$result
$result
Definition:
product_configurable_not_available_rollback.php:26
Magento\Sales\Service\V1\ShipmentAddTrackTest\SERVICE_READ_NAME
const SERVICE_READ_NAME
Definition:
ShipmentAddTrackTest.php:23
Magento\Sales\Api\Data\ShipmentTrackInterface\DESCRIPTION
const DESCRIPTION
Definition:
ShipmentTrackInterface.php:51
Magento\Sales\Model\Order\Shipment\Track\CUSTOM_CARRIER_CODE
const CUSTOM_CARRIER_CODE
Definition:
Track.php:24
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\Sales\Api\Data\ShipmentTrackInterface\TRACK_NUMBER
const TRACK_NUMBER
Definition:
ShipmentTrackInterface.php:47
Magento\Sales\Api\Data\ShipmentTrackInterface\CARRIER_CODE
const CARRIER_CODE
Definition:
ShipmentTrackInterface.php:59
Magento\Sales\Api\Data\ShipmentTrackInterface\ORDER_ID
const ORDER_ID
Definition:
ShipmentTrackInterface.php:43
Magento\Sales\Api\Data\ShipmentTrackInterface\TITLE
const TITLE
Definition:
ShipmentTrackInterface.php:55
Magento\Sales\Service\V1
Definition:
CreditmemoAddCommentTest.php:6
Magento\Sales\Service\V1\ShipmentAddTrackTest\setUp
setUp()
Definition:
ShipmentAddTrackTest.php:43
Magento\Sales\Model\ResourceModel\Order\Shipment\Collection
Definition:
Collection.php:18
Magento\Sales\Api\Data\ShipmentTrackInterface\ENTITY_ID
const ENTITY_ID
Definition:
ShipmentTrackInterface.php:27
Magento\Sales\Api\Data\ShipmentTrackInterface\PARENT_ID
const PARENT_ID
Definition:
ShipmentTrackInterface.php:31
Magento\Sales\Api\Data\ShipmentTrackInterface\QTY
const QTY
Definition:
ShipmentTrackInterface.php:39
Magento\Sales\Model\Order\Shipment\Track
Definition:
Validator.php:7
Magento\Framework\Webapi\Rest\Request\HTTP_METHOD_POST
const HTTP_METHOD_POST
Definition:
Request.php:22
Magento\Sales\Api\Data\ShipmentTrackInterface\WEIGHT
const WEIGHT
Definition:
ShipmentTrackInterface.php:35
Magento\Sales\Api\Data\ShipmentTrackInterface
Definition:
ShipmentTrackInterface.php:19
Magento\Framework\Webapi\Rest\Request
Magento\TestFramework\TestCase\WebapiAbstract
Definition:
WebapiAbstract.php:19
Magento\Sales\Service\V1\ShipmentAddTrackTest\SHIPMENT_INCREMENT_ID
const SHIPMENT_INCREMENT_ID
Definition:
ShipmentAddTrackTest.php:33
$shipment
foreach($order->getItems() as $orderItem) $shipment
Definition:
order_with_shipping_and_invoice.php:46
Magento\Sales\Service\V1\ShipmentAddTrackTest
Definition:
ShipmentAddTrackTest.php:18
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125