Пример #1
0
 /**
  * Tests client request with exception
  *
  * @return void
  */
 public function testSendRequestException()
 {
     $accId = '';
     $this->zendClientFactoryMock->expects($this->once())->method('create')->willReturn($this->zendClientMock);
     $this->configMock->expects($this->once())->method('getNewRelicAccountId')->willReturn($accId);
     $this->setExpectedException('Magento\\Framework\\Exception\\LocalizedException');
     $this->model->sendRequest();
 }
 /**
  * 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());
 }