52 $this->config = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Config::class)
53 ->disableOriginalConstructor()
54 ->setMethods([
'isNewRelicEnabled'])
56 $this->customerSession = $this->getMockBuilder(\
Magento\Customer\Model\Session::class)
57 ->disableOriginalConstructor()
58 ->setMethods([
'isLoggedIn',
'getCustomerId'])
60 $this->customerRepository = $this->getMockBuilder(\
Magento\Customer\Api\CustomerRepositoryInterface::class)
62 $this->storeManager = $this->getMockBuilder(\
Magento\Store\Model\StoreManagerInterface::class)
64 $this->newRelicWrapper = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\NewRelicWrapper::class)
65 ->disableOriginalConstructor()
66 ->setMethods([
'addCustomParameter'])
71 $this->customerSession,
72 $this->customerRepository,
74 $this->newRelicWrapper
83 public function testReportConcurrentUsersToNewRelicModuleDisabledFromConfig()
86 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
87 ->disableOriginalConstructor()
90 $this->config->expects($this->once())
91 ->method(
'isNewRelicEnabled')
94 $this->model->execute($eventObserver);
102 public function testReportConcurrentUsersToNewRelicUserIsNotLoggedIn()
105 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
106 ->disableOriginalConstructor()
109 $this->config->expects($this->once())
110 ->method(
'isNewRelicEnabled')
112 $this->customerSession->expects($this->once())
113 ->method(
'isLoggedIn')
115 $storeMock = $this->getMockBuilder(\
Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
116 $this->storeManager->expects($this->once())
118 ->willReturn($storeMock);
119 $websiteMock = $this->getMockBuilder(
120 \
Magento\Store\Model\Website::class
121 )->disableOriginalConstructor()->getMock();
122 $this->storeManager->expects($this->once())
123 ->method(
'getWebsite')
124 ->willReturn($websiteMock);
125 $this->newRelicWrapper->expects($this->exactly(2))
126 ->method(
'addCustomParameter')
129 $this->model->execute($eventObserver);
137 public function testReportConcurrentUsersToNewRelic()
142 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
143 ->disableOriginalConstructor()
146 $this->config->expects($this->once())
147 ->method(
'isNewRelicEnabled')
149 $this->customerSession->expects($this->once())
150 ->method(
'isLoggedIn')
152 $this->customerSession->expects($this->once())
153 ->method(
'getCustomerId')
154 ->willReturn($testCustomerId);
155 $customerMock = $this->getMockBuilder(\
Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
156 $this->customerRepository->expects($this->once())
158 ->willReturn($customerMock);
159 $storeMock = $this->getMockBuilder(\
Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
160 $this->storeManager->expects($this->once())
162 ->willReturn($storeMock);
163 $websiteMock = $this->getMockBuilder(
164 \
Magento\Store\Model\Website::class
165 )->disableOriginalConstructor()->getMock();
166 $this->storeManager->expects($this->once())
167 ->method(
'getWebsite')
168 ->willReturn($websiteMock);
169 $this->newRelicWrapper->expects($this->exactly(4))
170 ->method(
'addCustomParameter')
173 $this->model->execute($eventObserver);