コード例 #1
0
 /**
  * Update all charts for one specific user
  * @param string $userName
  */
 private function updateChartsForUser($userName)
 {
     $provider = $this->dataProviderFactory->getDataProviderByConfig($this->getDefaultChartConfig($userName));
     $storageUsage = $provider->getChartUsageForUpdate();
     $storage = $this->mapStorageUsageToStorageInformation($storageUsage);
     $this->contentStatisticsClient->commit($storage);
 }
コード例 #2
0
 public function testGetDataProviderByConfig()
 {
     $mock1 = clone $this->config;
     $mock1->expects($this->once())->method('getChartType')->willReturn("StorageUsageCurrent");
     $provider = $this->factory->getDataProviderByConfig($mock1);
     $this->assertInstanceOf('OCA\\ocUsageCharts\\DataProviders\\Storage\\StorageUsageCurrentProvider', $provider);
     $mock2 = clone $this->config;
     $mock2->expects($this->once())->method('getChartType')->willReturn("StorageUsageLastMonth");
     $provider = $this->factory->getDataProviderByConfig($mock2);
     $this->assertInstanceOf('OCA\\ocUsageCharts\\DataProviders\\Storage\\StorageUsageLastMonthProvider', $provider);
     $mock3 = clone $this->config;
     $mock3->expects($this->once())->method('getChartType')->willReturn("StorageUsagePerMonth");
     $provider = $this->factory->getDataProviderByConfig($mock3);
     $this->assertInstanceOf('OCA\\ocUsageCharts\\DataProviders\\Storage\\StorageUsagePerMonthProvider', $provider);
     $mock4 = clone $this->config;
     $mock4->expects($this->once())->method('getChartType')->willReturn("ActivityUsageLastMonth");
     $provider = $this->factory->getDataProviderByConfig($mock4);
     $this->assertInstanceOf('OCA\\ocUsageCharts\\DataProviders\\Activity\\ActivityUsageLastMonthProvider', $provider);
     $mock5 = clone $this->config;
     $mock5->expects($this->once())->method('getChartType')->willReturn("ActivityUsagePerMonth");
     $provider = $this->factory->getDataProviderByConfig($mock5);
     $this->assertInstanceOf('OCA\\ocUsageCharts\\DataProviders\\Activity\\ActivityUsagePerMonthProvider', $provider);
     $this->setExpectedException('OCA\\ocUsageCharts\\Exception\\ChartDataProviderException');
     $mock6 = clone $this->config;
     $mock6->expects($this->exactly(2))->method('getChartType')->willReturn("undefined");
     $this->factory->getDataProviderByConfig($mock6);
 }
コード例 #3
0
 /**
  * This method returns all usage for a chart based on the chartconfig given
  *
  * @param ChartConfig $chartConfig
  * @return array
  */
 public function getChartUsage(ChartConfig $chartConfig)
 {
     $provider = $this->dataProviderFactory->getDataProviderByConfig($chartConfig);
     $data = $provider->getChartUsage();
     $adapter = $this->chartTypeAdapterFactory->getChartTypeAdapterByConfig($chartConfig);
     return $adapter->formatData($data);
 }
コード例 #4
0
 public function testIsAllowedToUpdateSucceeded()
 {
     $provider = $this->getMockBuilder('OCA\\ocUsageCharts\\DataProviders\\Storage\\StorageUsageCurrentProvider')->disableOriginalConstructor()->getMock();
     $provider->expects($this->once())->method('isAllowedToUpdate')->willReturn(true);
     $this->dataProviderFactory->method('getDataProviderByConfig')->willReturn($provider);
     $this->assertTrue($this->dataProvider->isAllowedToUpdate($this->configMock));
 }
コード例 #5
0
 /**
  * @param ChartConfig $config
  * @return DataProviderInterface
  *
  * @throws \OCA\ocUsageCharts\Exception\ChartDataProviderException
  */
 private function getDataProviderByConfig(ChartConfig $config)
 {
     return $this->dataProviderFactory->getDataProviderByConfig($this->container, $config);
 }