9 use \Magento\Sales\Helper\Reorder;
48 $this->scopeConfigMock = $this->getMockBuilder(\
Magento\Framework\
App\Config::class)
49 ->setMethods([
'getValue'])
50 ->disableOriginalConstructor()
52 $contextMock = $this->getMockBuilder(\
Magento\Framework\
App\Helper\Context::class)
53 ->disableOriginalConstructor()
55 $contextMock->expects($this->any())
56 ->method(
'getScopeConfig')
57 ->willReturn($this->scopeConfigMock);
59 $this->customerSessionMock = $this->getMockBuilder(\
Magento\Customer\Model\Session::class)
60 ->disableOriginalConstructor()
63 $this->repositoryMock = $this->getMockBuilder(\
Magento\Sales\Api\OrderRepositoryInterface::class)
64 ->getMockForAbstractClass();
65 $this->helper = new \Magento\Sales\Helper\Reorder(
67 $this->customerSessionMock,
71 $this->storeParam = $this->getMockBuilder(\
Magento\Sales\Model\Store::class)
72 ->disableOriginalConstructor()
75 $this->orderMock = $this->getMockBuilder(\
Magento\Sales\Model\Order::class)
76 ->disableOriginalConstructor()
89 $this->assertEquals($scopeConfigValue, $this->helper->isAllowed($this->storeParam));
100 $this->storeParam =
null;
102 $this->assertEquals($scopeConfigValue, $this->helper->isAllow());
124 $this->scopeConfigMock->expects($this->once())
128 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE,
131 ->will($this->returnValue($returnValue));
142 $this->repositoryMock->expects($this->once())
145 ->willReturn($this->orderMock);
146 $this->assertFalse($this->helper->canReorder(1));
158 $this->customerSessionMock->expects($this->once())
159 ->method(
'isLoggedIn')
160 ->will($this->returnValue(
false));
161 $this->repositoryMock->expects($this->once())
164 ->willReturn($this->orderMock);
165 $this->assertTrue($this->helper->canReorder(1));
179 $this->customerSessionMock->expects($this->once())
180 ->method(
'isLoggedIn')
181 ->will($this->returnValue(
true));
183 $this->orderMock->expects($this->once())
184 ->method(
'canReorder')
185 ->will($this->returnValue($orderCanReorder));
186 $this->repositoryMock->expects($this->once())
189 ->willReturn($this->orderMock);
190 $this->assertEquals($orderCanReorder, $this->helper->canReorder(1));
202 $this->orderMock->expects($this->once())
204 ->will($this->returnValue($this->storeParam));
testIsAllowedScopeConfigReorder($scopeConfigValue)
testIsAllowScopeConfigReorderNotAllowWithStore($scopeConfigValue)
setupScopeConfigMock($returnValue)
const XML_PATH_SALES_REORDER_ALLOW
testCanReorderCustomerLoggedInAndOrderCanReorder($orderCanReorder)
setupOrderMock($storeScopeReturnValue)
testCanReorderCustomerNotLoggedIn()
testCanReorderStoreNotAllowed()