Skip to content

Commit

Permalink
magento#10803 update OrderService to return correct bool value for ca…
Browse files Browse the repository at this point in the history
…ncel method
  • Loading branch information
freakphp committed Sep 17, 2017
1 parent e649b4c commit db79dbf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/code/Magento/Sales/Model/Service/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public function __construct(
public function cancel($id)
{
$order = $this->orderRepository->get($id);
if ((bool)$order->cancel()) {
if ((bool)$order->canCancel()) {
$order->cancel();
$this->orderRepository->save($order);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,30 @@ public function testCancel()
$this->orderMock->expects($this->once())
->method('cancel')
->willReturn($this->orderMock);
$this->orderMock->expects($this->once())
->method('canCancel')
->willReturn(true);
$this->assertTrue($this->orderService->cancel(123));
}

/**
* test for Order::cancel() fail case
*/
public function testCancelFailed()
{
$this->orderRepositoryMock->expects($this->once())
->method('get')
->with(123)
->willReturn($this->orderMock);
$this->orderMock->expects($this->never())
->method('cancel')
->willReturn($this->orderMock);
$this->orderMock->expects($this->once())
->method('canCancel')
->willReturn(false);
$this->assertFalse($this->orderService->cancel(123));
}

public function testGetCommentsList()
{
$this->filterBuilderMock->expects($this->once())
Expand Down

0 comments on commit db79dbf

Please sign in to comment.