Skip to content

Commit 2dd91d0

Browse files
Stanislav Idolovgelanivishal
authored andcommitted
magento#14629 Fixed test failures
1 parent ef7bde6 commit 2dd91d0

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
@@ -29,13 +29,19 @@ class MassUnhold extends AbstractMassAction
2929
* @param Context $context
3030
* @param Filter $filter
3131
* @param CollectionFactory $collectionFactory
32-
* @param OrderManagementInterface $orderManagement
32+
* @param OrderManagementInterface|null $orderManagement
3333
*/
34-
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory, OrderManagementInterface $orderManagement)
35-
{
34+
public function __construct(
35+
Context $context,
36+
Filter $filter,
37+
CollectionFactory $collectionFactory,
38+
OrderManagementInterface $orderManagement = null
39+
) {
3640
parent::__construct($context, $filter);
3741
$this->collectionFactory = $collectionFactory;
38-
$this->orderManagement = $orderManagement ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Sales\Api\OrderManagementInterface::class);
42+
$this->orderManagement = $orderManagement ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
43+
\Magento\Sales\Api\OrderManagementInterface::class
44+
);
3945
}
4046

4147
/**

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);
@@ -158,12 +163,15 @@ protected function setUp()
158163
->method('create')
159164
->willReturn($this->orderCollectionMock);
160165

166+
$this->orderManagementMock = $this->createMock(\Magento\Sales\Api\OrderManagementInterface::class);
167+
161168
$this->massAction = $objectManagerHelper->getObject(
162169
'Magento\Sales\Controller\Adminhtml\Order\MassUnhold',
163170
[
164171
'context' => $this->contextMock,
165172
'filter' => $this->filterMock,
166-
'collectionFactory' => $this->orderCollectionFactoryMock
173+
'collectionFactory' => $this->orderCollectionFactoryMock,
174+
'orderManagement' => $this->orderManagementMock
167175
]
168176
);
169177
}
@@ -187,9 +195,7 @@ public function testExecuteOneOrdersReleasedFromHold()
187195
->method('canUnhold')
188196
->willReturn(true);
189197
$order1->expects($this->once())
190-
->method('unhold');
191-
$order1->expects($this->once())
192-
->method('save');
198+
->method('getEntityId');
193199

194200
$this->orderCollectionMock->expects($this->once())
195201
->method('count')
@@ -199,6 +205,8 @@ public function testExecuteOneOrdersReleasedFromHold()
199205
->method('canUnhold')
200206
->willReturn(false);
201207

208+
$this->orderManagementMock->expects($this->atLeastOnce())->method('unHold')->willReturn(true);
209+
202210
$this->messageManagerMock->expects($this->once())
203211
->method('addError')
204212
->with('1 order(s) were not released from on hold status.');

0 commit comments

Comments
 (0)