File tree 5 files changed +6
-26
lines changed
ResourceModel/Order/Shipment
Test/Unit/Model/ResourceModel/Order/Shipment
Shipping/Test/Unit/Model/Order
dev/tests/api-functional/testsuite/Magento/Sales/Service/V1 5 files changed +6
-26
lines changed Original file line number Diff line number Diff line change 6
6
namespace Magento \Sales \Model \Order \Shipment ;
7
7
8
8
use Magento \Framework \Api \AttributeValueFactory ;
9
- use Magento \Framework \Exception \LocalizedException ;
10
9
use Magento \Sales \Api \Data \ShipmentTrackInterface ;
11
10
use Magento \Sales \Model \AbstractModel ;
12
11
@@ -138,16 +137,11 @@ public function setShipment(\Magento\Sales\Model\Order\Shipment $shipment)
138
137
* Retrieve Shipment instance
139
138
*
140
139
* @return \Magento\Sales\Model\Order\Shipment
141
- * @throws \Magento\Framework\Exception\LocalizedException
142
140
*/
143
141
public function getShipment ()
144
142
{
145
143
if (!$ this ->_shipment instanceof \Magento \Sales \Model \Order \Shipment) {
146
- if ($ this ->getParentId ()) {
147
- $ this ->_shipment = $ this ->shipmentRepository ->get ($ this ->getParentId ());
148
- } else {
149
- throw new LocalizedException (__ ("Parent shipment cannot be loaded for track object. " ));
150
- }
144
+ $ this ->_shipment = $ this ->shipmentRepository ->get ($ this ->getParentId ());
151
145
}
152
146
153
147
return $ this ->_shipment ;
@@ -214,7 +208,6 @@ public function addData(array $data)
214
208
}
215
209
216
210
//@codeCoverageIgnoreStart
217
-
218
211
/**
219
212
* Returns track_number
220
213
*
@@ -415,6 +408,5 @@ public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentTrackExte
415
408
{
416
409
return $ this ->_setExtensionAttributes ($ extensionAttributes );
417
410
}
418
-
419
411
//@codeCoverageIgnoreEnd
420
412
}
Original file line number Diff line number Diff line change @@ -64,13 +64,11 @@ public function processRelation(\Magento\Framework\Model\AbstractModel $object)
64
64
}
65
65
if (null !== $ object ->getTracks ()) {
66
66
foreach ($ object ->getTracks () as $ track ) {
67
- $ track ->setParentId ($ object ->getId ());
68
67
$ this ->shipmentTrackResource ->save ($ track );
69
68
}
70
69
}
71
70
if (null !== $ object ->getComments ()) {
72
71
foreach ($ object ->getComments () as $ comment ) {
73
- $ comment ->setParentId ($ object ->getId ());
74
72
$ this ->shipmentCommentResource ->save ($ comment );
75
73
}
76
74
}
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ protected function setUp()
111
111
112
112
public function testProcessRelations ()
113
113
{
114
- $ this ->shipmentMock ->expects ($ this ->exactly ( 3 ))
114
+ $ this ->shipmentMock ->expects ($ this ->once ( ))
115
115
->method ('getId ' )
116
116
->willReturn ('shipment-id-value ' );
117
117
$ this ->shipmentMock ->expects ($ this ->exactly (2 ))
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public function testLookup()
52
52
'Magento\Shipping\Model\Order\Track ' ,
53
53
['carrierFactory ' => $ carrierFactory , 'shipmentRepository ' => $ shipmentRepository ]
54
54
);
55
- $ model -> setParentId ( 1 );
55
+
56
56
$ this ->assertEquals ('trackingInfo ' , $ model ->getNumberDetail ());
57
57
}
58
58
}
Original file line number Diff line number Diff line change @@ -79,21 +79,11 @@ public function testInvoke()
79
79
'increment_id ' => null ,
80
80
'created_at ' => null ,
81
81
'updated_at ' => null ,
82
+ // 'packages' => null,
82
83
'shipping_label ' => null ,
83
- 'tracks ' => [
84
- [
85
- 'carrier_code ' => 'UPS ' ,
86
- 'order_id ' => $ order ->getId (),
87
- 'title ' => 'ground ' ,
88
- 'track_number ' => '12345678 '
89
- ]
90
- ],
84
+ 'tracks ' => [],
91
85
'items ' => $ items ,
92
- 'comments ' => [
93
- [
94
- 'comment ' => 'Shipment-related comment. '
95
- ]
96
- ],
86
+ 'comments ' => [],
97
87
];
98
88
$ result = $ this ->_webApiCall ($ serviceInfo , ['entity ' => $ data ]);
99
89
$ this ->assertNotEmpty ($ result );
You can’t perform that action at this time.
0 commit comments