File tree Expand file tree Collapse file tree 5 files changed +12
-10
lines changed
Controller/Adminhtml/Order/Shipment
Test/Unit/Controller/Adminhtml/Order/Shipment Expand file tree Collapse file tree 5 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public function __construct(
2929 /**
3030 * @inheritdoc
3131 */
32- public function getShipment (): array
32+ public function getShipmentData (): array
3333 {
3434 $ sourceCode = $ this ->request ->getParam ('sourceCode ' );
3535 $ items = $ this ->request ->getParam ('items ' , []);
Original file line number Diff line number Diff line change 77namespace Magento \Shipping \Controller \Adminhtml \Order \Shipment ;
88
99use Magento \Backend \App \Action ;
10+ use Magento \Framework \App \ObjectManager ;
1011
1112class NewAction extends \Magento \Backend \App \Action
1213{
@@ -35,10 +36,11 @@ class NewAction extends \Magento\Backend\App\Action
3536 public function __construct (
3637 Action \Context $ context ,
3738 \Magento \Shipping \Controller \Adminhtml \Order \ShipmentLoader $ shipmentLoader ,
38- \Magento \Shipping \Model \ShipmentProviderInterface $ shipmentProvider
39+ \Magento \Shipping \Model \ShipmentProviderInterface $ shipmentProvider = null
3940 ) {
4041 $ this ->shipmentLoader = $ shipmentLoader ;
41- $ this ->shipmentProvider = $ shipmentProvider ;
42+ $ this ->shipmentProvider = $ shipmentProvider ?: ObjectManager::getInstance ()
43+ ->get (\Magento \Shipping \Model \ShipmentProviderInterface::class);
4244 parent ::__construct ($ context );
4345 }
4446
@@ -51,7 +53,7 @@ public function execute()
5153 {
5254 $ this ->shipmentLoader ->setOrderId ($ this ->getRequest ()->getParam ('order_id ' ));
5355 $ this ->shipmentLoader ->setShipmentId ($ this ->getRequest ()->getParam ('shipment_id ' ));
54- $ this ->shipmentLoader ->setShipment ($ this ->shipmentProvider ->getShipment ());
56+ $ this ->shipmentLoader ->setShipment ($ this ->shipmentProvider ->getShipmentData ());
5557 $ this ->shipmentLoader ->setTracking ($ this ->getRequest ()->getParam ('tracking ' ));
5658 $ shipment = $ this ->shipmentLoader ->load ();
5759 if ($ shipment ) {
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ public function __construct(RequestInterface $request)
3030 /**
3131 * @inheritdoc
3232 */
33- public function getShipment (): array
33+ public function getShipmentData (): array
3434 {
3535 return $ this ->request ->getParam ('shipment ' , []);
3636 }
Original file line number Diff line number Diff line change 88namespace Magento \Shipping \Model ;
99
1010/**
11- * Provide shipment items data from request .
11+ * Provide shipment items data.
1212 *
1313 * @api
1414 */
1515interface ShipmentProviderInterface
1616{
1717 /**
18- * Retrieve shipment items from request .
18+ * Retrieve shipment items.
1919 *
2020 * @return array
2121 */
22- public function getShipment (): array ;
22+ public function getShipmentData (): array ;
2323}
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ protected function setUp()
135135 );
136136 $ this ->shipmentProviderMock = $ this ->getMockBuilder (\Magento \Shipping \Model \ShipmentProviderInterface::class)
137137 ->disableOriginalConstructor ()
138- ->setMethods (['getShipment ' ])
138+ ->setMethods (['getShipmentData ' ])
139139 ->getMockForAbstractClass ();
140140 $ this ->actionFlag = $ this ->createPartialMock (\Magento \Framework \App \ActionFlag::class, ['get ' ]);
141141 $ this ->helper = $ this ->createPartialMock (\Magento \Backend \Helper \Data::class, ['getUrl ' ]);
@@ -270,7 +270,7 @@ public function testExecute()
270270 ->with ('menu ' )
271271 ->will ($ this ->returnValue ($ menuBlock ));
272272 $ this ->shipmentProviderMock ->expects ($ this ->once ())
273- ->method ('getShipment ' )
273+ ->method ('getShipmentData ' )
274274 ->willReturn ($ shipmentData );
275275
276276 $ this ->assertNull ($ this ->newAction ->execute ());
You can’t perform that action at this time.
0 commit comments