71 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
72 $this->layoutMock = $this->createMock(\
Magento\Framework\View\Layout::class);
73 $this->customerInterfaceFactoryMock = $this->createPartialMock(
74 \
Magento\Customer\Api\Data\CustomerInterfaceFactory::class,
75 [
'create',
'setGroupId']
77 $this->customerDataMock = $this->createMock(\
Magento\Customer\Api\Data\CustomerInterface::class);
78 $this->customerRepositoryMock = $this->createMock(\
Magento\Customer\Api\CustomerRepositoryInterface::class);
79 $this->requestMock = $this->createMock(\
Magento\Framework\
App\Request\Http::class);
80 $this->moduleManagerMock = $this->createMock(\
Magento\Framework\Module\Manager::class);
81 $this->viewMock = $this->createMock(\
Magento\Framework\
App\View::class);
83 $this->currentCustomer = new \Magento\Customer\Helper\Session\CurrentCustomer(
84 $this->customerSessionMock,
86 $this->customerInterfaceFactoryMock,
87 $this->customerRepositoryMock,
89 $this->moduleManagerMock,
99 $this->requestMock->expects($this->once())->method(
'isAjax')->will($this->returnValue(
false));
100 $this->layoutMock->expects($this->once())->method(
'isCacheable')->will($this->returnValue(
true));
101 $this->viewMock->expects($this->once())->method(
'isLayoutLoaded')->will($this->returnValue(
true));
102 $this->moduleManagerMock->expects($this->once())
103 ->method(
'isEnabled')
104 ->with($this->equalTo(
'Magento_PageCache'))
105 ->will($this->returnValue(
true));
106 $this->customerSessionMock->expects($this->once())
107 ->method(
'getCustomerGroupId')
108 ->will($this->returnValue($this->customerGroupId));
109 $this->customerInterfaceFactoryMock->expects($this->once())
111 ->will($this->returnValue($this->customerDataMock));
112 $this->customerDataMock->expects($this->once())
113 ->method(
'setGroupId')
114 ->with($this->equalTo($this->customerGroupId))
115 ->will($this->returnSelf());
116 $this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
124 $this->moduleManagerMock->expects($this->once())
125 ->method(
'isEnabled')
126 ->with($this->equalTo(
'Magento_PageCache'))
127 ->will($this->returnValue(
false));
128 $this->customerSessionMock->expects($this->once())
130 ->will($this->returnValue($this->customerId));
131 $this->customerRepositoryMock->expects($this->once())
133 ->with($this->equalTo($this->customerId))
134 ->will($this->returnValue($this->customerDataMock));
135 $this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
testGetCustomerDepersonalizeCustomerData()
$customerInterfaceFactoryMock
testGetCustomerLoadCustomerFromService()