/** * Test case when cron is enabled in config * * @return \Magento\NewRelicReporting\Model\Cron */ public function testRunCronCronEnabledFromConfig() { $this->configMock->expects($this->once())->method('isCronEnabled')->willReturn(true); $this->reportModulesInfoMock->expects($this->once())->method('report')->willReturnSelf(); $this->reportCountsMock->expects($this->once())->method('report')->willReturnSelf(); $this->reportNewRelicCronMock->expects($this->once())->method('report')->willReturnSelf(); $this->assertSame($this->model, $this->model->runCron()); }
/** * The method run by the cron that fires all required events. * * @return \Magento\NewRelicReporting\Model\Cron */ public function runCron() { if ($this->config->isCronEnabled()) { $this->reportNewRelicCron->report(); $this->reportModulesInfo->report(); $this->reportCounts->report(); } return $this; }
/** * Test case when module is enabled and request is failed * * @return void */ public function testReportNewRelicCronRequestFailed() { $testModuleData = ['changes' => [['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'enabled'], ['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'disabled'], ['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'installed'], ['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'uninstalled']], 'enabled' => 1, 'disabled' => 1, 'installed' => 1]; $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true); $this->collect->expects($this->once())->method('getModuleData')->willReturn($testModuleData); $this->counter->expects($this->once())->method('getAllProductsCount'); $this->counter->expects($this->once())->method('getConfigurableCount'); $this->counter->expects($this->once())->method('getActiveCatalogSize'); $this->counter->expects($this->once())->method('getCategoryCount'); $this->counter->expects($this->once())->method('getWebsiteCount'); $this->counter->expects($this->once())->method('getStoreViewsCount'); $this->counter->expects($this->once())->method('getCustomerCount'); $this->cronEventModel->expects($this->once())->method('addData')->willReturnSelf(); $this->cronEventModel->expects($this->once())->method('sendRequest'); $this->cronEventModel->expects($this->once())->method('sendRequest')->willThrowException(new \Exception()); $this->logger->expects($this->once())->method('critical'); $this->deploymentsModel->expects($this->any())->method('setDeployment'); $this->assertSame($this->model, $this->model->report()); }