Skip to content

Commit d4c762f

Browse files
author
Stanislav Idolov
committed
#14629 Fixed test failures
1 parent 74da688 commit d4c762f

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ class MassUnhold extends AbstractMassAction
2727
* @param Context $context
2828
* @param Filter $filter
2929
* @param CollectionFactory $collectionFactory
30-
* @param OrderManagementInterface $orderManagement
30+
* @param OrderManagementInterface|null $orderManagement
3131
*/
32-
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory, OrderManagementInterface $orderManagement)
33-
{
32+
public function __construct(
33+
Context $context,
34+
Filter $filter,
35+
CollectionFactory $collectionFactory,
36+
OrderManagementInterface $orderManagement = null
37+
) {
3438
parent::__construct($context, $filter);
3539
$this->collectionFactory = $collectionFactory;
36-
$this->orderManagement = $orderManagement ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Sales\Api\OrderManagementInterface::class);
40+
$this->orderManagement = $orderManagement ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
41+
\Magento\Sales\Api\OrderManagementInterface::class
42+
);
3743
}
3844

3945
/**

app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ class MassUnholdTest extends \PHPUnit\Framework\TestCase
8585
*/
8686
protected $filterMock;
8787

88+
/**
89+
* @var \PHPUnit_Framework_MockObject_MockObject
90+
*/
91+
private $orderManagementMock;
92+
8893
protected function setUp()
8994
{
9095
$objectManagerHelper = new ObjectManagerHelper($this);
@@ -146,12 +151,15 @@ protected function setUp()
146151
->method('create')
147152
->willReturn($this->orderCollectionMock);
148153

154+
$this->orderManagementMock = $this->createMock(\Magento\Sales\Api\OrderManagementInterface::class);
155+
149156
$this->massAction = $objectManagerHelper->getObject(
150157
\Magento\Sales\Controller\Adminhtml\Order\MassUnhold::class,
151158
[
152159
'context' => $this->contextMock,
153160
'filter' => $this->filterMock,
154-
'collectionFactory' => $this->orderCollectionFactoryMock
161+
'collectionFactory' => $this->orderCollectionFactoryMock,
162+
'orderManagement' => $this->orderManagementMock
155163
]
156164
);
157165
}
@@ -175,9 +183,7 @@ public function testExecuteOneOrdersReleasedFromHold()
175183
->method('canUnhold')
176184
->willReturn(true);
177185
$order1->expects($this->once())
178-
->method('unhold');
179-
$order1->expects($this->once())
180-
->method('save');
186+
->method('getEntityId');
181187

182188
$this->orderCollectionMock->expects($this->once())
183189
->method('count')
@@ -187,6 +193,8 @@ public function testExecuteOneOrdersReleasedFromHold()
187193
->method('canUnhold')
188194
->willReturn(false);
189195

196+
$this->orderManagementMock->expects($this->atLeastOnce())->method('unHold')->willReturn(true);
197+
190198
$this->messageManagerMock->expects($this->once())
191199
->method('addError')
192200
->with('1 order(s) were not released from on hold status.');

0 commit comments

Comments
 (0)