67 $this->config = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Config::class)
68 ->disableOriginalConstructor()
69 ->setMethods([
'isNewRelicEnabled'])
71 $this->collect = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Module\Collect::class)
72 ->disableOriginalConstructor()
73 ->setMethods([
'getModuleData'])
75 $this->counter = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Counter::class)
76 ->disableOriginalConstructor()
78 'getAllProductsCount',
79 'getConfigurableCount',
80 'getActiveCatalogSize',
87 $this->cronEventFactory = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\CronEventFactory::class)
88 ->disableOriginalConstructor()
89 ->setMethods([
'create'])
91 $this->cronEventModel = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\CronEvent::class)
92 ->disableOriginalConstructor()
93 ->setMethods([
'addData',
'sendRequest'])
95 $this->deploymentsFactory = $this->getMockBuilder(
96 \
Magento\NewRelicReporting\Model\Apm\DeploymentsFactory::class
97 )->disableOriginalConstructor()
98 ->setMethods([
'create'])
100 $this->deploymentsModel = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Apm\Deployments::class)
101 ->disableOriginalConstructor()
102 ->setMethods([
'setDeployment'])
105 $this->cronEventFactory->expects($this->any())
107 ->willReturn($this->cronEventModel);
108 $this->deploymentsFactory->expects($this->any())
110 ->willReturn($this->deploymentsModel);
111 $this->logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class);
117 $this->cronEventFactory,
118 $this->deploymentsFactory,
130 $this->config->expects($this->once())
131 ->method(
'isNewRelicEnabled')
136 $this->model->report()
148 $this->config->expects($this->once())
149 ->method(
'isNewRelicEnabled')
151 $this->counter->expects($this->once())
152 ->method(
'getAllProductsCount');
153 $this->counter->expects($this->once())
154 ->method(
'getConfigurableCount');
155 $this->counter->expects($this->once())
156 ->method(
'getActiveCatalogSize');
157 $this->counter->expects($this->once())
158 ->method(
'getCategoryCount');
159 $this->counter->expects($this->once())
160 ->method(
'getWebsiteCount');
161 $this->counter->expects($this->once())
162 ->method(
'getStoreViewsCount');
163 $this->counter->expects($this->once())
164 ->method(
'getCustomerCount');
165 $this->cronEventModel->expects($this->once())
168 $this->cronEventModel->expects($this->once())
169 ->method(
'sendRequest');
171 $this->deploymentsModel->expects($this->any())
172 ->method(
'setDeployment');
176 $this->model->report()
188 $this->config->expects($this->once())
189 ->method(
'isNewRelicEnabled')
191 $this->counter->expects($this->once())
192 ->method(
'getAllProductsCount');
193 $this->counter->expects($this->once())
194 ->method(
'getConfigurableCount');
195 $this->counter->expects($this->once())
196 ->method(
'getActiveCatalogSize');
197 $this->counter->expects($this->once())
198 ->method(
'getCategoryCount');
199 $this->counter->expects($this->once())
200 ->method(
'getWebsiteCount');
201 $this->counter->expects($this->once())
202 ->method(
'getStoreViewsCount');
203 $this->counter->expects($this->once())
204 ->method(
'getCustomerCount');
205 $this->cronEventModel->expects($this->once())
208 $this->cronEventModel->expects($this->once())
209 ->method(
'sendRequest');
211 $this->cronEventModel->expects($this->once())->method(
'sendRequest')->willThrowException(
new \Exception());
212 $this->logger->expects($this->never())->method(
'critical');
214 $this->deploymentsModel->expects($this->any())
215 ->method(
'setDeployment');
217 $this->model->report();
testReportNewRelicCronModuleDisabledFromConfig()
testReportNewRelicCronRequestFailed()