Skip to content

Commit

Permalink
Ported Down changes from PR#10919
Browse files Browse the repository at this point in the history
From db79dbf Mon Sep 17 00:00:00 2001
From: freakphp <mail@freak.io>
Date: Sun, 17 Sep 2017 12:52:00 +0200
Subject: [PATCH 1/2] magento#10803 update OrderService to return correct bool value for cancel method

From d4cddf7 Mon Sep 17 00:00:00 2001
From: Ievgen Shakhsuvarov <ishakhsuvarov@users.noreply.github.com>
Date: Mon, 18 Sep 2017 12:22:00 +0200
Subject: [PATCH 2/2] magento#10919: update OrderService to return correct bool value
  • Loading branch information
strell authored and strelldev committed Sep 30, 2017
1 parent 0c0393d commit 2a9255c
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
Expand Up @@ -87,7 +87,8 @@ public function __construct(
public function cancel($id)
{
$order = $this->orderRepository->get($id);
if ((bool)$order->cancel()) {
if ($order->canCancel()) {
$order->cancel();
$this->orderRepository->save($order);
return true;
}
Expand Down
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 2a9255c

Please sign in to comment.