9
9
namespace Magento \Shipping \Test \Unit \Controller \Adminhtml \Order \Shipment ;
10
10
11
11
use Magento \Backend \App \Action ;
12
+ use Magento \Sales \Model \ValidatorResultInterface ;
12
13
use Magento \Sales \Model \Order \Email \Sender \ShipmentSender ;
13
14
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
14
15
use Magento \Sales \Model \Order \Shipment \ShipmentValidatorInterface ;
@@ -96,6 +97,11 @@ class SaveTest extends \PHPUnit_Framework_TestCase
96
97
*/
97
98
private $ shipmentValidatorMock ;
98
99
100
+ /**
101
+ * @var ValidatorResultInterface|\PHPUnit_Framework_MockObject_MockObject
102
+ */
103
+ private $ validationResult ;
104
+
99
105
/**
100
106
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
101
107
*/
@@ -107,6 +113,9 @@ protected function setUp()
107
113
->disableOriginalConstructor ()
108
114
->setMethods ([])
109
115
->getMock ();
116
+ $ this ->validationResult = $ this ->getMockBuilder (ValidatorResultInterface::class)
117
+ ->disableOriginalConstructor ()
118
+ ->getMock ();
110
119
$ this ->labelGenerator = $ this ->getMockBuilder (\Magento \Shipping \Model \Shipping \LabelGenerator::class)
111
120
->disableOriginalConstructor ()
112
121
->setMethods ([])
@@ -362,7 +371,11 @@ public function testExecute($formKeyIsValid, $isPost)
362
371
$ this ->shipmentValidatorMock ->expects ($ this ->once ())
363
372
->method ('validate ' )
364
373
->with ($ shipment , [QuantityValidator::class])
365
- ->willReturn ([]);
374
+ ->willReturn ($ this ->validationResult );
375
+
376
+ $ this ->validationResult ->expects ($ this ->once ())
377
+ ->method ('hasMessages ' )
378
+ ->willReturn (false );
366
379
367
380
$ this ->saveAction ->execute ();
368
381
$ this ->assertEquals ($ this ->response , $ this ->saveAction ->getResponse ());
0 commit comments