/**
  * Return the chart data you want to return based on the ChartConfig
  *
  * @param User $user
  * @param ActivityUsageRepository|StorageUsageRepository $repository
  * @param ChartConfig $chartConfig
  * @return mixed
  */
 public function getChartUsage(User $user, $repository, ChartConfig $chartConfig)
 {
     if ($user->isAdminUser($user->getSignedInUsername())) {
         $data = $repository->findAllPerMonth();
     } else {
         $data = $repository->findAllPerMonth($chartConfig->getUsername());
     }
     return $data;
 }
 public function testSaveFalse()
 {
     $usageMock = $this->getMockBuilder('OCA\\ocUsageCharts\\Entity\\Storage\\StorageUsage')->disableOriginalConstructor()->getMock();
     $this->repository->expects($this->once())->method('save')->willReturn(false);
     $result = $this->abstractProvider->save($usageMock);
     $this->assertFalse($result);
 }
 /**
  * Save the usage
  *
  * @param StorageUsage $usage
  * @return boolean
  */
 public function save($usage)
 {
     return $this->repository->save($usage);
 }