/** * Test case when module is enabled in config * * @return void */ public function testReportSystemCacheFlushToNewRelic() { /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */ $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock(); $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true); $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->getMock(); $this->backendAuthSession->expects($this->once())->method('getUser')->willReturn($userMock); $userMock->expects($this->once())->method('getId')->willReturn('2'); $this->deploymentsFactory->expects($this->once())->method('create')->willReturn($this->deploymentsModel); $this->deploymentsModel->expects($this->once())->method('setDeployment')->willReturnSelf(); $this->model->execute($eventObserver); }
/** * 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()); }