Skip to content

Commit f449e5b

Browse files
Merge remote-tracking branch '39601/bug/issue-39568-reorder-bug' into marcomprs
2 parents 41b1208 + 664a863 commit f449e5b

File tree

2 files changed

+9
-53
lines changed

2 files changed

+9
-53
lines changed

app/code/Magento/Sales/Helper/Reorder.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Sales\Helper;
@@ -11,12 +11,7 @@
1111
*/
1212
class Reorder extends \Magento\Framework\App\Helper\AbstractHelper
1313
{
14-
const XML_PATH_SALES_REORDER_ALLOW = 'sales/reorder/allow';
15-
16-
/**
17-
* @var \Magento\Customer\Model\Session
18-
*/
19-
protected $customerSession;
14+
public const XML_PATH_SALES_REORDER_ALLOW = 'sales/reorder/allow';
2015

2116
/**
2217
* @var \Magento\Sales\Api\OrderRepositoryInterface
@@ -25,22 +20,21 @@ class Reorder extends \Magento\Framework\App\Helper\AbstractHelper
2520

2621
/**
2722
* @param \Magento\Framework\App\Helper\Context $context
28-
* @param \Magento\Customer\Model\Session $customerSession
2923
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
3024
*/
3125
public function __construct(
3226
\Magento\Framework\App\Helper\Context $context,
33-
\Magento\Customer\Model\Session $customerSession,
3427
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository
3528
) {
3629
$this->orderRepository = $orderRepository;
37-
$this->customerSession = $customerSession;
3830
parent::__construct(
3931
$context
4032
);
4133
}
4234

4335
/**
36+
* Check if reorder is allowed
37+
*
4438
* @return bool
4539
*/
4640
public function isAllow()
@@ -78,10 +72,6 @@ public function canReorder($orderId)
7872
if (!$this->isAllowed($order->getStore())) {
7973
return false;
8074
}
81-
if ($this->customerSession->isLoggedIn()) {
82-
return $order->canReorder();
83-
} else {
84-
return true;
85-
}
75+
return $order->canReorder();
8676
}
8777
}

app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\Sales\Test\Unit\Helper;
99

10-
use Magento\Customer\Model\Session;
1110
use Magento\Framework\App\Config;
1211
use Magento\Framework\App\Config\ScopeConfigInterface;
1312
use Magento\Framework\App\Helper\Context;
@@ -40,11 +39,6 @@ class ReorderTest extends TestCase
4039
*/
4140
protected $orderMock;
4241

43-
/**
44-
* @var MockObject|Session
45-
*/
46-
protected $customerSessionMock;
47-
4842
/**
4943
* @var OrderRepositoryInterface|MockObject
5044
*/
@@ -66,15 +60,10 @@ protected function setUp(): void
6660
->method('getScopeConfig')
6761
->willReturn($this->scopeConfigMock);
6862

69-
$this->customerSessionMock = $this->getMockBuilder(Session::class)
70-
->disableOriginalConstructor()
71-
->getMock();
72-
7363
$this->repositoryMock = $this->getMockBuilder(OrderRepositoryInterface::class)
7464
->getMockForAbstractClass();
7565
$this->helper = new Reorder(
7666
$contextMock,
77-
$this->customerSessionMock,
7867
$this->repositoryMock
7968
);
8069

@@ -156,40 +145,17 @@ public function testCanReorderStoreNotAllowed()
156145
$this->assertFalse($this->helper->canReorder(1));
157146
}
158147

159-
/**
160-
* Tests what happens if the customer is not logged in and the store does allow re-orders.
161-
*
162-
* @return void
163-
*/
164-
public function testCanReorderCustomerNotLoggedIn()
165-
{
166-
$this->setupOrderMock(true);
167-
168-
$this->customerSessionMock->expects($this->once())
169-
->method('isLoggedIn')
170-
->willReturn(false);
171-
$this->repositoryMock->expects($this->once())
172-
->method('get')
173-
->with(1)
174-
->willReturn($this->orderMock);
175-
$this->assertTrue($this->helper->canReorder(1));
176-
}
177-
178148
/**
179149
* Tests what happens if the customer is logged in and the order does or does not allow reorders.
180150
*
181151
* @param bool $orderCanReorder
182152
* @return void
183153
* @dataProvider getOrderCanReorder
184154
*/
185-
public function testCanReorderCustomerLoggedInAndOrderCanReorder($orderCanReorder)
155+
public function testCanReorder($orderCanReorder)
186156
{
187157
$this->setupOrderMock(true);
188158

189-
$this->customerSessionMock->expects($this->once())
190-
->method('isLoggedIn')
191-
->willReturn(true);
192-
193159
$this->orderMock->expects($this->once())
194160
->method('canReorder')
195161
->willReturn($orderCanReorder);

0 commit comments

Comments
 (0)