@@ -102,21 +102,22 @@ class SaveTest extends \PHPUnit_Framework_TestCase
102
102
protected function setUp ()
103
103
{
104
104
$ objectManagerHelper = new ObjectManagerHelper ($ this );
105
- $ this ->shipmentLoader = $ this ->getMockBuilder ('Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader ' )
105
+ $ this ->shipmentLoader = $ this ->getMockBuilder (
106
+ \Magento \Shipping \Controller \Adminhtml \Order \ShipmentLoader::class)
106
107
->disableOriginalConstructor ()
107
108
->setMethods ([])
108
109
->getMock ();
109
- $ this ->labelGenerator = $ this ->getMockBuilder (' Magento\Shipping\Model\Shipping\LabelGenerator ' )
110
+ $ this ->labelGenerator = $ this ->getMockBuilder (\ Magento \Shipping \Model \Shipping \LabelGenerator::class )
110
111
->disableOriginalConstructor ()
111
112
->setMethods ([])
112
113
->getMock ();
113
- $ this ->shipmentSender = $ this ->getMockBuilder (' Magento\Sales\Model\Order\Email\Sender\ShipmentSender ' )
114
+ $ this ->shipmentSender = $ this ->getMockBuilder (\ Magento \Sales \Model \Order \Email \Sender \ShipmentSender::class )
114
115
->disableOriginalConstructor ()
115
116
->setMethods ([])
116
117
->getMock ();
117
- $ this ->objectManager = $ this ->getMock (' Magento\Framework\ObjectManagerInterface ' );
118
+ $ this ->objectManager = $ this ->getMock (\ Magento \Framework \ObjectManagerInterface::class );
118
119
$ this ->context = $ this ->getMock (
119
- ' Magento\Backend\App\Action\Context ' ,
120
+ \ Magento \Backend \App \Action \Context::class ,
120
121
[
121
122
'getRequest ' , 'getResponse ' , 'getMessageManager ' , 'getRedirect ' ,
122
123
'getObjectManager ' , 'getSession ' , 'getActionFlag ' , 'getHelper ' ,
@@ -127,40 +128,40 @@ protected function setUp()
127
128
false
128
129
);
129
130
$ this ->response = $ this ->getMock (
130
- ' Magento\Framework\App\ResponseInterface ' ,
131
+ \ Magento \Framework \App \ResponseInterface::class ,
131
132
['setRedirect ' , 'sendResponse ' ],
132
133
[],
133
134
'' ,
134
135
false
135
136
);
136
- $ this ->request = $ this ->getMockBuilder (' Magento\Framework\App\Request\Http ' )
137
+ $ this ->request = $ this ->getMockBuilder (\ Magento \Framework \App \Request \Http::class )
137
138
->disableOriginalConstructor ()->getMock ();
138
139
$ this ->objectManager = $ this ->getMock (
139
- ' Magento\Framework\ObjectManager\ObjectManager ' ,
140
+ \ Magento \Framework \ObjectManager \ObjectManager::class ,
140
141
['create ' , 'get ' ],
141
142
[],
142
143
'' ,
143
144
false
144
145
);
145
146
$ this ->messageManager = $ this ->getMock (
146
- ' Magento\Framework\Message\Manager ' ,
147
+ \ Magento \Framework \Message \Manager::class ,
147
148
['addSuccess ' , 'addError ' ],
148
149
[],
149
150
'' ,
150
151
false
151
152
);
152
153
$ this ->session = $ this ->getMock (
153
- ' Magento\Backend\Model\Session ' ,
154
+ \ Magento \Backend \Model \Session::class ,
154
155
['setIsUrlNotice ' , 'getCommentText ' ],
155
156
[],
156
157
'' ,
157
158
false
158
159
);
159
- $ this ->actionFlag = $ this ->getMock (' Magento\Framework\App\ActionFlag ' , ['get ' ], [], '' , false );
160
- $ this ->helper = $ this ->getMock (' Magento\Backend\Helper\Data ' , ['getUrl ' ], [], '' , false );
160
+ $ this ->actionFlag = $ this ->getMock (\ Magento \Framework \App \ActionFlag::class , ['get ' ], [], '' , false );
161
+ $ this ->helper = $ this ->getMock (\ Magento \Backend \Helper \Data::class , ['getUrl ' ], [], '' , false );
161
162
162
163
$ this ->resultRedirect = $ this ->getMock (
163
- ' Magento\Framework\Controller\Result\Redirect ' ,
164
+ \ Magento \Framework \Controller \Result \Redirect::class ,
164
165
['setPath ' ],
165
166
[],
166
167
'' ,
@@ -171,7 +172,7 @@ protected function setUp()
171
172
->willReturn ($ this ->resultRedirect );
172
173
173
174
$ resultRedirectFactory = $ this ->getMock (
174
- ' Magento\Framework\Controller\Result\RedirectFactory ' ,
175
+ \ Magento \Framework \Controller \Result \RedirectFactory::class ,
175
176
['create ' ],
176
177
[],
177
178
'' ,
@@ -182,7 +183,7 @@ protected function setUp()
182
183
->willReturn ($ this ->resultRedirect );
183
184
184
185
$ this ->formKeyValidator = $ this ->getMock (
185
- ' Magento\Framework\Data\Form\FormKey\Validator ' ,
186
+ \ Magento \Framework \Data \Form \FormKey \Validator::class ,
186
187
['validate ' ],
187
188
[],
188
189
'' ,
@@ -222,7 +223,7 @@ protected function setUp()
222
223
->getMock ();
223
224
224
225
$ this ->saveAction = $ objectManagerHelper ->getObject (
225
- ' Magento\Shipping\Controller\Adminhtml\Order\Shipment\Save ' ,
226
+ \ Magento \Shipping \Controller \Adminhtml \Order \Shipment \Save::class ,
226
227
[
227
228
'labelGenerator ' => $ this ->labelGenerator ,
228
229
'shipmentSender ' => $ this ->shipmentSender ,
@@ -250,7 +251,6 @@ public function testExecute($formKeyIsValid, $isPost)
250
251
$ this ->request ->expects ($ this ->any ())
251
252
->method ('isPost ' )
252
253
->willReturn ($ isPost );
253
-
254
254
if (!$ formKeyIsValid || !$ isPost ) {
255
255
$ this ->messageManager ->expects ($ this ->once ())
256
256
->method ('addError ' );
@@ -269,14 +269,14 @@ public function testExecute($formKeyIsValid, $isPost)
269
269
$ tracking = [];
270
270
$ shipmentData = ['items ' => [], 'send_email ' => '' ];
271
271
$ shipment = $ this ->getMock (
272
- ' Magento\Sales\Model\Order\Shipment ' ,
272
+ \ Magento \Sales \Model \Order \Shipment::class ,
273
273
['load ' , 'save ' , 'register ' , 'getOrder ' , 'getOrderId ' , '__wakeup ' ],
274
274
[],
275
275
'' ,
276
276
false
277
277
);
278
278
$ order = $ this ->getMock (
279
- ' Magento\Sales\Model\Order ' ,
279
+ \ Magento \Sales \Model \Order::class ,
280
280
['setCustomerNoteNotify ' , '__wakeup ' ],
281
281
[],
282
282
'' ,
@@ -324,7 +324,7 @@ public function testExecute($formKeyIsValid, $isPost)
324
324
->method ('create ' )
325
325
->with ($ shipment , $ this ->request )
326
326
->will ($ this ->returnValue (true ));
327
- $ saveTransaction = $ this ->getMockBuilder (' Magento\Framework\DB\Transaction ' )
327
+ $ saveTransaction = $ this ->getMockBuilder (\ Magento \Framework \DB \Transaction::class )
328
328
->disableOriginalConstructor ()
329
329
->setMethods ([])
330
330
->getMock ();
@@ -342,15 +342,17 @@ public function testExecute($formKeyIsValid, $isPost)
342
342
$ this ->session ->expects ($ this ->once ())
343
343
->method ('getCommentText ' )
344
344
->with (true );
345
-
346
345
$ this ->objectManager ->expects ($ this ->once ())
347
346
->method ('create ' )
348
- ->with (' Magento\Framework\DB\Transaction ' )
347
+ ->with (\ Magento \Framework \DB \Transaction::class )
349
348
->will ($ this ->returnValue ($ saveTransaction ));
350
- $ this ->objectManager ->expects ($ this ->once ( ))
349
+ $ this ->objectManager ->expects ($ this ->exactly ( 2 ))
351
350
->method ('get ' )
352
- ->with ('Magento\Backend\Model\Session ' )
353
- ->will ($ this ->returnValue ($ this ->session ));
351
+ ->withConsecutive (
352
+ [\Magento \Sales \Model \Order \Shipment \ShipmentValidatorInterface::class],
353
+ [\Magento \Backend \Model \Session::class]
354
+ )
355
+ ->willReturnOnConsecutiveCalls ($ this ->shipmentValidatorMock , $ this ->session );
354
356
$ path = 'sales/order/view ' ;
355
357
$ arguments = ['order_id ' => $ orderId ];
356
358
$ shipment ->expects ($ this ->once ())
0 commit comments