1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
*/
namespace Temando\Shipping\Model;
use Magento\TestFramework\ObjectManager;
use Magento\TestFramework\Helper\Bootstrap;
use Temando\Shipping\Api\Data\Shipment\ShipmentReferenceInterface;
/**
* Temando Shipment Reference Test
*
* @package Temando\Shipping\Test\Integration
* @author Benjamin Heuer <benjamin.heuer@netresearch.de>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.temando.com/
*/
class ShipmentReferenceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
*/
private $objectManager;
/**
* Init object manager
*/
public function setUp()
{
parent::setUp();
$this->objectManager = Bootstrap::getObjectManager();
}
/**
* @test
*/
public function dataIsSetThroughConstructorArgument()
{
$entityId = 303;
$shipmentId = 808;
$shipmentReferenceId = 'F00-S01';
$locationReferenceId = 'F00-L01';
$trackingReferenceId = 'F00-T01';
$trackingUrl = 'https://example.org/';
/** @var ShipmentReferenceInterface $shipmentReference */
$shipmentReference = $this->objectManager->create(ShipmentReferenceInterface::class, ['data' => [
ShipmentReferenceInterface::ENTITY_ID => $entityId,
ShipmentReferenceInterface::SHIPMENT_ID => $shipmentId,
ShipmentReferenceInterface::EXT_SHIPMENT_ID => $shipmentReferenceId,
ShipmentReferenceInterface::EXT_LOCATION_ID => $locationReferenceId,
ShipmentReferenceInterface::EXT_TRACKING_REFERENCE => $trackingReferenceId,
ShipmentReferenceInterface::EXT_TRACKING_URL => $trackingUrl,
]]);
$this->assertEquals($entityId, $shipmentReference->getEntityId());
$this->assertEquals($shipmentId, $shipmentReference->getShipmentId());
$this->assertEquals($shipmentReferenceId, $shipmentReference->getExtShipmentId());
$this->assertEquals($locationReferenceId, $shipmentReference->getExtLocationId());
$this->assertEquals($trackingReferenceId, $shipmentReference->getExtTrackingReference());
$this->assertEquals($trackingUrl, $shipmentReference->getExtTrackingUrl());
}
/**
* @test
*/
public function dataIsSetThroughSetters()
{
$entityId = 303;
$shipmentId = 808;
$shipmentReferenceId = 'F00-S01';
$locationReferenceId = 'F00-L01';
$trackingReferenceId = 'F00-T01';
$trackingUrl = 'https://example.org/';
/** @var ShipmentReferenceInterface $shipmentReference */
$shipmentReference = $this->objectManager->create(ShipmentReferenceInterface::class);
$this->assertEmpty($shipmentReference->getEntityId());
$shipmentReference->setEntityId($entityId);
$this->assertEquals($entityId, $shipmentReference->getEntityId());
$shipmentReference->setShipmentId($shipmentId);
$this->assertEquals($shipmentId, $shipmentReference->getShipmentId());
$shipmentReference->setExtShipmentId($shipmentReferenceId);
$this->assertEquals($shipmentReferenceId, $shipmentReference->getExtShipmentId());
$shipmentReference->setExtLocationId($locationReferenceId);
$this->assertEquals($locationReferenceId, $shipmentReference->getExtLocationId());
$shipmentReference->setExtTrackingReference($trackingReferenceId);
$this->assertEquals($trackingReferenceId, $shipmentReference->getExtTrackingReference());
$shipmentReference->setExtTrackingUrl($trackingUrl);
$this->assertEquals($trackingUrl, $shipmentReference->getExtTrackingUrl());
}
}