/**
  * @expectedException \Application\Exceptions\NotAllowedException
  * @expectedExceptionMessage Create report Operation is not allowed: Too many reports created. The limit is 20 generated reports
  */
 public function testCreate()
 {
     $reportModel = $this->getMock('Application\\Model\\Stream\\StreamResultModel', array());
     $type = ReportModel::ACCUMULATED_SUMMARY_DAILY;
     $dumpReport = new ReportModel();
     $dumpReport->setType($type);
     $reportModel->expects($this->any())->method('count')->will($this->returnValue(20));
     $this->_reportService->setListAll($reportModel);
     $this->_reportService->create($dumpReport);
 }
 /**
  * Get an specific report by its Id
  */
 public function getAction()
 {
     $output = $this->getRequest()->getParam('output', 'json');
     $type = $this->getRequest()->getParam('id');
     // Custom download report name
     if ($type !== ReportModel::KPI_MONTHLY) {
         throw new InvalidArgumentException("Only Report KPI/ARPU available.");
     }
     // Check report permissions by type
     $dumpReport = new ReportModel();
     $dumpReport->setType($type);
     $this->_helper->allowed('read', $dumpReport);
     if ($output !== 'json') {
         throw new InvalidArgumentException("Only JSON output available.");
     }
     $helper = $this->_helper->output('Stream_Json');
     // Load report
     $params = $this->getRequest()->getParams();
     $params['type'] = $type;
     $this->view->data = \Application\Service\ReportService::getInstance()->load($type, $params);
     if (is_null($this->view->data)) {
         throw new \Application\Exceptions\NotFoundException("Report not available");
     }
     if (isset($params['requiredFields'])) {
         $requiredFields = explode(':', $params['requiredFields']);
         $this->view->setAllowedFields($requiredFields);
     }
     if (isset($params['skipEmptyItems']) && $params['skipEmptyItems']) {
         $this->view->setSkipEmptyItems(true);
     }
     $helper->addHeaders();
     $this->getResponse()->sendHeaders();
     $this->view->render('');
     $this->_helper->forceExit();
 }
 public function validateParams($type, &$params = array())
 {
     try {
         parent::validateParams($type, $params);
     } catch (InvalidArgumentException $e) {
         // Dirty solution, but in near future parent class will be disappear,
         // and it will be not necessary
         if ($e->getMessage() == 'Invalid report type') {
             switch ($type) {
                 case ReportModel::SMIP_CONSUMPTION_MONTHLY:
                     $this->validateParamsSmipConsumptionMonthly($params);
                     break;
                 case ReportModel::SMIP_CONSUMPTION_DAILY:
                     $this->validateParamsSmipConsumptionDaily($params);
                     break;
                 default:
                     throw $e;
             }
         } else {
             throw $e;
         }
     }
 }
 /**
  * @expectedException Application\Exceptions\NotFoundException
  **/
 public function testGetExpenseMonthlyDetailByBillingCycleStartDoesNotExist()
 {
     $params = array(ReportFilterFields::REPORT_TYPE => ReportModel::EXPENSE_DETAIL_MONTHLY, ReportFilterFields::ORGANIZATION => self::CUSTOMER_ORG_ID, ReportFilterFields::BILLING_ACCOUNT => "0", 'date' => '2012-11', 'billingcyclestartday' => '13');
     $data = $this->_reportService->load(ReportModel::EXPENSE_DETAIL_MONTHLY, $params);
 }
 public function init()
 {
     $this->_downloadTokenSrv = Download\Service\DownloadTokenService::getInstance();
     $this->_reportSrv = ReportService::getInstance();
 }
 public function init()
 {
     $this->_reportSrv = \Application\Service\ReportService::getInstance();
 }