├── Api ├── AutomatedExportLinkRepositoryInterface.php ├── AutomatedExportRepositoryInterface.php ├── CreateDynamicCronInterface.php ├── CustomReportRepositoryInterface.php ├── Data │ ├── AutomatedExportInterface.php │ ├── AutomatedExportLinkInterface.php │ └── CustomReportInterface.php └── DeleteDynamicCronInterface.php ├── Block └── Adminhtml │ ├── AutomatedExport │ └── Edit │ │ ├── BackButton.php │ │ ├── DeleteButton.php │ │ ├── GenericButton.php │ │ ├── ResetButton.php │ │ ├── SaveAndContinueButton.php │ │ └── SaveButton.php │ ├── CustomReport │ └── Edit │ │ ├── BackButton.php │ │ ├── DeleteButton.php │ │ ├── GenericButton.php │ │ ├── ResetButton.php │ │ ├── SaveAndContinueButton.php │ │ └── SaveButton.php │ ├── Report.php │ └── Report │ ├── Export.php │ └── Grid.php ├── Controller └── Adminhtml │ ├── AutomatedExport │ ├── Builder.php │ ├── Delete.php │ ├── Edit.php │ ├── ExportCsv.php │ ├── ExportXml.php │ ├── Listing.php │ ├── NewAction.php │ ├── Report.php │ └── Save.php │ └── CustomReport │ ├── Builder.php │ ├── Delete.php │ ├── Edit.php │ ├── ExportCsv.php │ ├── ExportXml.php │ ├── Listing.php │ ├── NewAction.php │ ├── Report.php │ └── Save.php ├── Model ├── AutomatedExport.php ├── AutomatedExport │ ├── Cron.php │ └── DataProvider.php ├── AutomatedExportLink.php ├── AutomatedExportLinkRepository.php ├── AutomatedExportRepository.php ├── Config │ └── Source │ │ ├── AutomatedExports.php │ │ ├── CustomReports.php │ │ ├── ExportType.php │ │ └── FileType.php ├── CustomReport.php ├── CustomReport │ └── DataProvider.php ├── CustomReportRepository.php ├── GenericReportCollection.php ├── ResourceModel │ ├── AutomatedExport.php │ ├── AutomatedExport │ │ └── Collection.php │ ├── AutomatedExportLink.php │ ├── AutomatedExportLink │ │ └── Collection.php │ ├── CustomReport.php │ └── CustomReport │ │ └── Collection.php └── Service │ ├── CreateDynamicCron.php │ └── DeleteDynamicCron.php ├── README.md ├── Registry └── CurrentCustomReport.php ├── Test └── Unit │ ├── Block │ └── Adminhtml │ │ ├── AutomatedExport │ │ └── Edit │ │ │ ├── BackButtonTest.php │ │ │ ├── DeleteButtonTest.php │ │ │ ├── ResetButtonTest.php │ │ │ ├── SaveAndContinueButtonTest.php │ │ │ └── SaveButtonTest.php │ │ ├── CustomReport │ │ └── Edit │ │ │ ├── BackButtonTest.php │ │ │ ├── DeleteButtonTest.php │ │ │ ├── ResetButtonTest.php │ │ │ ├── SaveAndContinueButtonTest.php │ │ │ └── SaveButtonTest.php │ │ └── Report │ │ ├── GridTest.php │ │ └── ReportTest.php │ ├── Controller │ └── Adminhtml │ │ ├── AutomatedExport │ │ ├── BuilderTest.php │ │ ├── DeleteTest.php │ │ ├── EditTest.php │ │ ├── ExportCsvTest.php │ │ ├── ExportXmlTest.php │ │ ├── ListingTest.php │ │ ├── NewActionTest.php │ │ ├── ReportTest.php │ │ └── SaveTest.php │ │ └── CustomReport │ │ ├── BuilderTest.php │ │ ├── DeleteTest.php │ │ ├── EditTest.php │ │ ├── ExportCsvTest.php │ │ ├── ExportXmlTest.php │ │ ├── ListingTest.php │ │ ├── NewActionTest.php │ │ ├── ReportTest.php │ │ └── SaveTest.php │ └── Model │ ├── AutomatedExport │ ├── CronTest.php │ └── DataProviderTest.php │ ├── AutomatedExportLinkRepositoryTest.php │ ├── AutomatedExportRepositoryTest.php │ ├── Config │ └── Source │ │ ├── AutomatedExportsTest.php │ │ └── CustomReportsTest.php │ ├── CustomReport │ └── DataProviderTest.php │ ├── CustomReportRepositoryTest.php │ └── Service │ ├── CreateDynamicCronTest.php │ └── DeleteDynamicCronTest.php ├── Ui └── Component │ └── Listing │ ├── Column │ ├── AutomatedExport │ │ └── PageActions.php │ └── CustomReport │ │ └── PageActions.php │ └── DataProviders │ ├── AutomatedExport │ └── Listing.php │ └── CustomReport │ └── Listing.php ├── composer.json ├── etc ├── acl.xml ├── adminhtml │ ├── menu.xml │ └── routes.xml ├── db_schema.xml ├── di.xml └── module.xml ├── registration.php └── view └── adminhtml ├── layout ├── deg_customreports_automatedexport_edit.xml ├── deg_customreports_automatedexport_listing.xml ├── deg_customreports_automatedexport_new.xml ├── deg_customreports_automatedexport_save.xml ├── deg_customreports_customreport_edit.xml ├── deg_customreports_customreport_listing.xml ├── deg_customreports_customreport_new.xml ├── deg_customreports_customreport_report.xml └── deg_customreports_customreport_save.xml └── ui_component ├── automatedexport_form.xml ├── automatedexport_listing.xml ├── customreport_form.xml └── customreport_listing.xml /Api/AutomatedExportLinkRepositoryInterface.php: -------------------------------------------------------------------------------- 1 | __('Back'), 16 | 'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()), 17 | 'class' => 'back', 18 | 'sort_order' => 10, 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Block/Adminhtml/AutomatedExport/Edit/DeleteButton.php: -------------------------------------------------------------------------------- 1 | getObjectId()) { 15 | return []; 16 | } 17 | 18 | return [ 19 | 'label' => __('Delete Report'), 20 | 'class' => 'delete', 21 | 'on_click' => 'deleteConfirm( \''.__( 22 | 'Are you sure you want to do this?' 23 | ).'\', \''.$this->getDeleteUrl().'\')', 24 | 'sort_order' => 20, 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Block/Adminhtml/AutomatedExport/Edit/GenericButton.php: -------------------------------------------------------------------------------- 1 | context = $context; 25 | } 26 | 27 | /** 28 | * @return string 29 | */ 30 | public function getBackUrl(): string 31 | { 32 | return $this->getUrl('*/*/listing'); 33 | } 34 | 35 | /** 36 | * @return string 37 | */ 38 | public function getDeleteUrl(): string 39 | { 40 | return $this->getUrl('*/*/delete', ['object_id' => $this->getObjectId()]); 41 | } 42 | 43 | /** 44 | * @param string $route 45 | * @param array $params 46 | * 47 | * @return string 48 | */ 49 | public function getUrl($route = '', $params = []): string 50 | { 51 | return $this->context->getUrlBuilder()->getUrl($route, $params); 52 | } 53 | 54 | /** 55 | * @return mixed 56 | */ 57 | public function getObjectId() 58 | { 59 | return $this->context->getRequest()->getParam('automatedexport_id'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Block/Adminhtml/AutomatedExport/Edit/ResetButton.php: -------------------------------------------------------------------------------- 1 | __('Reset'), 16 | 'class' => 'reset', 17 | 'on_click' => 'location.reload();', 18 | 'sort_order' => 30, 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Block/Adminhtml/AutomatedExport/Edit/SaveAndContinueButton.php: -------------------------------------------------------------------------------- 1 | __('Save and Continue Edit'), 16 | 'class' => 'save', 17 | 'data_attribute' => [ 18 | 'mage-init' => [ 19 | 'button' => ['event' => 'saveAndContinueEdit'], 20 | ], 21 | ], 22 | 'sort_order' => 80, 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Block/Adminhtml/AutomatedExport/Edit/SaveButton.php: -------------------------------------------------------------------------------- 1 | __('Save Report'), 16 | 'class' => 'save primary', 17 | 'data_attribute' => [ 18 | 'mage-init' => ['button' => ['event' => 'save']], 19 | 'form-role' => 'save', 20 | ], 21 | 'sort_order' => 90, 22 | ]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Block/Adminhtml/CustomReport/Edit/BackButton.php: -------------------------------------------------------------------------------- 1 | __('Back'), 16 | 'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()), 17 | 'class' => 'back', 18 | 'sort_order' => 10, 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Block/Adminhtml/CustomReport/Edit/DeleteButton.php: -------------------------------------------------------------------------------- 1 | getObjectId()) { 15 | return []; 16 | } 17 | 18 | return [ 19 | 'label' => __('Delete Report'), 20 | 'class' => 'delete', 21 | 'on_click' => 'deleteConfirm( \''.__( 22 | 'Are you sure you want to do this?' 23 | ).'\', \''.$this->getDeleteUrl().'\')', 24 | 'sort_order' => 20, 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Block/Adminhtml/CustomReport/Edit/GenericButton.php: -------------------------------------------------------------------------------- 1 | context = $context; 25 | } 26 | 27 | /** 28 | * @return string 29 | */ 30 | public function getBackUrl(): string 31 | { 32 | return $this->getUrl('*/*/listing'); 33 | } 34 | 35 | /** 36 | * @return string 37 | */ 38 | public function getDeleteUrl(): string 39 | { 40 | return $this->getUrl('*/*/delete', ['object_id' => $this->getObjectId()]); 41 | } 42 | 43 | /** 44 | * @param string $route 45 | * @param array $params 46 | * 47 | * @return string 48 | */ 49 | public function getUrl($route = '', $params = []): string 50 | { 51 | return $this->context->getUrlBuilder()->getUrl($route, $params); 52 | } 53 | 54 | /** 55 | * @return mixed 56 | */ 57 | public function getObjectId() 58 | { 59 | return $this->context->getRequest()->getParam('customreport_id'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Block/Adminhtml/CustomReport/Edit/ResetButton.php: -------------------------------------------------------------------------------- 1 | __('Reset'), 16 | 'class' => 'reset', 17 | 'on_click' => 'location.reload();', 18 | 'sort_order' => 30, 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Block/Adminhtml/CustomReport/Edit/SaveAndContinueButton.php: -------------------------------------------------------------------------------- 1 | __('Save and Continue Edit'), 16 | 'class' => 'save', 17 | 'data_attribute' => [ 18 | 'mage-init' => [ 19 | 'button' => ['event' => 'saveAndContinueEdit'], 20 | ], 21 | ], 22 | 'sort_order' => 80, 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Block/Adminhtml/CustomReport/Edit/SaveButton.php: -------------------------------------------------------------------------------- 1 | __('Save Report'), 16 | 'class' => 'save primary', 17 | 'data_attribute' => [ 18 | 'mage-init' => ['button' => ['event' => 'save']], 19 | 'form-role' => 'save', 20 | ], 21 | 'sort_order' => 90, 22 | ]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Block/Adminhtml/Report.php: -------------------------------------------------------------------------------- 1 | getUrl('*/*/listing'); 15 | } 16 | 17 | /** 18 | * constructor 19 | * 20 | * @return void 21 | */ 22 | protected function _construct() 23 | { 24 | $this->_controller = 'adminhtml_report'; 25 | $this->_blockGroup = 'DEG_CustomReports'; 26 | $this->_headerText = __('Report'); 27 | parent::_construct(); 28 | $this->removeButton('add'); 29 | $this->_addBackButton(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Block/Adminhtml/Report/Grid.php: -------------------------------------------------------------------------------- 1 | currentCustomReportRegistry = $currentCustomReportRegistry; 34 | } 35 | 36 | public function _prepareLayout() 37 | { 38 | $customReport = $this->currentCustomReportRegistry->get(); 39 | $genericCollection = $customReport->getGenericReportCollection(); 40 | $columnList = $this->getColumnListFromCollection($genericCollection); 41 | if (is_object($genericCollection)) { 42 | $this->addColumnSet($columnList); 43 | $this->addGridExportBlock(); 44 | $this->setCollection($genericCollection); 45 | } 46 | parent::_prepareLayout(); 47 | } 48 | 49 | /** 50 | * @param $collection 51 | * 52 | * @return mixed 53 | */ 54 | public function getColumnListFromCollection($collection) 55 | { 56 | $columnsCollection = clone $collection; 57 | $columnsCollection->getSelect()->limitPage(1, 1); 58 | 59 | return $columnsCollection->getFirstItem(); 60 | } 61 | 62 | /** 63 | * @param $dataItem 64 | */ 65 | public function addColumnSet($dataItem) 66 | { 67 | /** @var $columnSet \Magento\Backend\Block\Widget\Grid\ColumnSet * */ 68 | $columnSet = $this->_layout->createBlock( 69 | ColumnSet::class, 70 | 'deg_customreports_grid.grid.columnSet' 71 | ); 72 | foreach ($dataItem->getData() as $key => $val) { 73 | if ($this->_defaultSort === false) { 74 | $this->_defaultSort = $key; 75 | } 76 | /** @var $column \Magento\Backend\Block\Widget\Grid\Column * */ 77 | $data = [ 78 | 'data' => [ 79 | 'header' => $key, 80 | 'index' => $key, 81 | 'type' => 'text', 82 | ], 83 | ]; 84 | $column = $this->_layout->createBlock( 85 | Column::class, 86 | 'deg_customreports_grid.grid.column.'.$key, 87 | $data 88 | ); 89 | $columnSet->setChild($key, $column); 90 | } 91 | $this->setChild('grid.columnSet', $columnSet); 92 | } 93 | 94 | /** 95 | * Add the export block as a child block to the grid. 96 | * 97 | * @return $this 98 | */ 99 | public function addGridExportBlock(): Grid 100 | { 101 | $exportArguments = [ 102 | 'data' => [ 103 | 'exportTypes' => [ 104 | 'csv' => [ 105 | 'urlPath' => '*/*/exportCsv', 106 | 'label' => 'CSV', 107 | ], 108 | 'excel' => [ 109 | 'urlPath' => '*/*/exportXml', 110 | 'label' => 'Excel XML', 111 | ], 112 | ], 113 | ], 114 | ]; 115 | 116 | $exportBlock = $this->_layout->createBlock( 117 | Export::class, 118 | 'deg_customreports_grid.grid.export', 119 | $exportArguments 120 | ); 121 | $this->setChild('grid.export', $exportBlock); 122 | $exportBlock->lazyPrepareLayout(); 123 | 124 | return $this; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/Builder.php: -------------------------------------------------------------------------------- 1 | customReportFactory = $customReportFactory; 44 | $this->logger = $logger; 45 | $this->currentCustomReportRegistry = $currentCustomReportRegistry; 46 | $this->customReportRepository = $customReportRepository; 47 | } 48 | 49 | /** 50 | * Build custom report based on user request 51 | * 52 | * @param RequestInterface $request 53 | * 54 | * @return \DEG\CustomReports\Model\CustomReport 55 | */ 56 | public function build(RequestInterface $request): CustomReport 57 | { 58 | $customReportId = (int)$request->getParam('automatedexport_id'); 59 | $customReport = $this->customReportFactory->create(); 60 | if ($customReportId) { 61 | try { 62 | $customReport = $this->customReportRepository->getById($customReportId); 63 | } catch (NoSuchEntityException $e) { 64 | $this->logger->critical($e); 65 | } 66 | } 67 | 68 | $this->currentCustomReportRegistry->set($customReport); 69 | 70 | return $customReport; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/Delete.php: -------------------------------------------------------------------------------- 1 | autoExportReportRepository = $autoExportReportRepository; 32 | $this->deleteCronConfigData = $deleteCronConfigData; 33 | } 34 | 35 | /** 36 | * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface 37 | */ 38 | public function execute() 39 | { 40 | $id = $this->getRequest()->getParam('object_id'); 41 | $resultRedirect = $this->resultRedirectFactory->create(); 42 | if ($id) { 43 | try { 44 | $autoExport = $this->autoExportReportRepository->getById($id); 45 | if($autoExport->getId()){ 46 | $automatedExportModelName = 'automated_export_'.$autoExport->getId(); 47 | $this->deleteCronConfigData->execute($automatedExportModelName); 48 | $this->autoExportReportRepository->delete($autoExport); 49 | $this->messageManager->addSuccessMessage(__('You have deleted the report.')); 50 | } 51 | return $resultRedirect->setPath('*/*/listing'); 52 | 53 | } catch (Exception $e) { 54 | $this->messageManager->addErrorMessage($e->getMessage()); 55 | 56 | return $resultRedirect->setPath('*/*/edit', ['automatedexport_id' => $id]); 57 | } 58 | } 59 | $this->messageManager->addErrorMessage(__('We can not find a report to delete.')); 60 | 61 | return $resultRedirect->setPath('*/*/listing'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/Edit.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 28 | 29 | return parent::__construct($context); 30 | } 31 | 32 | /** 33 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 34 | */ 35 | public function execute() 36 | { 37 | $resultPage = $this->resultPageFactory->create(); 38 | $resultPage->setActiveMenu('DEG_CustomReports:automatedexport'); 39 | $resultPage->getConfig()->getTitle()->prepend(__('Edit Automated Export')); 40 | 41 | return $resultPage; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/ExportCsv.php: -------------------------------------------------------------------------------- 1 | fileFactory = $fileFactory; 37 | $this->builder = $builder; 38 | 39 | parent::__construct($context); 40 | } 41 | 42 | /** 43 | * Export customer grid to CSV format 44 | * 45 | * @return \Magento\Framework\App\ResponseInterface 46 | * @throws \Exception 47 | */ 48 | public function execute(): ResponseInterface 49 | { 50 | $customReport = $this->builder->build($this->getRequest()); 51 | 52 | $this->_view->loadLayout(); 53 | $fileName = $customReport->getReportName().'.csv'; 54 | 55 | /** @var @var $reportGrid \DEG\CustomReports\Block\Adminhtml\Report\Grid */ 56 | $reportGrid = $this->_view->getLayout() 57 | ->createBlock(Grid::class, 'report.grid'); 58 | /** @var Export $exportBlock */ 59 | $exportBlock = $reportGrid->getChildBlock('grid.export'); 60 | 61 | return $this->fileFactory->create( 62 | $fileName, 63 | $exportBlock->getCsvFile(), 64 | DirectoryList::VAR_DIR 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/ExportXml.php: -------------------------------------------------------------------------------- 1 | _fileFactory = $fileFactory; 37 | $this->builder = $builder; 38 | 39 | parent::__construct($context); 40 | } 41 | 42 | /** 43 | * Export customer grid to CSV format 44 | * 45 | * @return \Magento\Framework\App\ResponseInterface 46 | * @throws \Magento\Framework\Exception\FileSystemException 47 | * @throws \Exception 48 | */ 49 | public function execute(): ResponseInterface 50 | { 51 | /** @var $reportGrid \DEG\CustomReports\Block\Adminhtml\Report\Grid */ 52 | /** @var $exportBlock Export */ 53 | 54 | $customReport = $this->builder->build($this->getRequest()); 55 | $this->_view->loadLayout(); 56 | $fileName = $customReport->getReportName().'.xml'; 57 | $reportGrid = $this->_view->getLayout() 58 | ->createBlock(Grid::class, 'report.grid'); 59 | $exportBlock = $reportGrid->getChildBlock('grid.export'); 60 | 61 | return $this->_fileFactory->create( 62 | $fileName, 63 | $exportBlock->getExcelFile(), 64 | DirectoryList::VAR_DIR 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/Listing.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 29 | 30 | return parent::__construct($context); 31 | } 32 | 33 | /** 34 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 35 | */ 36 | public function execute() 37 | { 38 | $resultPage = $this->resultPageFactory->create(); 39 | $resultPage->setActiveMenu('DEG_CustomReports::automatedexport'); 40 | $resultPage->getConfig()->getTitle()->prepend(__('Manage Automated Exports')); 41 | 42 | return $resultPage; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/NewAction.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 28 | 29 | return parent::__construct($context); 30 | } 31 | 32 | /** 33 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 34 | */ 35 | public function execute() 36 | { 37 | $resultPage = $this->resultPageFactory->create(); 38 | $resultPage->setActiveMenu('DEG_CustomReports::automatedexport'); 39 | $resultPage->getConfig()->getTitle()->prepend(__('New Automated Export')); 40 | 41 | return $resultPage; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/Report.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 36 | $this->builder = $builder; 37 | 38 | return parent::__construct($context); 39 | } 40 | 41 | /** 42 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 43 | */ 44 | public function execute() 45 | { 46 | $customReport = $this->builder->build($this->getRequest()); 47 | $resultPage = $this->resultPageFactory->create(); 48 | $resultPage->setActiveMenu('DEG_CustomReports::automatedexport'); 49 | $resultPage->getConfig()->getTitle()->prepend($customReport->getReportName()); 50 | 51 | return $resultPage; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Controller/Adminhtml/AutomatedExport/Save.php: -------------------------------------------------------------------------------- 1 | dataPersistor = $dataPersistor; 45 | parent::__construct($context); 46 | $this->automatedExportRepository = $automatedExportRepository; 47 | $this->automatedExportFactory = $automatedExportFactory; 48 | } 49 | 50 | /** 51 | * Save action 52 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) 53 | * 54 | * @return \Magento\Framework\Controller\ResultInterface 55 | * @throws \Magento\Framework\Exception\NoSuchEntityException 56 | * @throws \Magento\Framework\Exception\NoSuchEntityException 57 | */ 58 | public function execute(): ResultInterface 59 | { 60 | $data = $this->getRequest()->getPostValue(); 61 | $resultRedirect = $this->resultRedirectFactory->create(); 62 | if ($data) { 63 | if (empty($data['automatedexport_id'])) { 64 | $data['automatedexport_id'] = null; 65 | } 66 | 67 | $automatedExport = $this->automatedExportFactory->create(); 68 | 69 | $id = $this->getRequest()->getParam('automatedexport_id'); 70 | if ($id) { 71 | $automatedExport = $this->automatedExportRepository->getById($id); 72 | } 73 | 74 | $automatedExport->setData($data); 75 | 76 | try { 77 | $this->automatedExportRepository->save($automatedExport); 78 | $this->messageManager->addSuccessMessage(__('You saved the automated export.')); 79 | $this->dataPersistor->clear('deg_customreports_automatedexport'); 80 | if ($this->getRequest()->getParam('back')) { 81 | return $resultRedirect->setPath( 82 | '*/*/edit', 83 | ['automatedexport_id' => $automatedExport->getId(), '_current' => true] 84 | ); 85 | } 86 | 87 | return $resultRedirect->setPath('*/*/listing'); 88 | } catch (LocalizedException $e) { 89 | $this->messageManager->addErrorMessage($e->getMessage()); 90 | } catch (Exception $e) { 91 | $this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the data.')); 92 | } 93 | 94 | $this->dataPersistor->set('deg_customreports_automatedexport', $data); 95 | 96 | return $resultRedirect->setPath( 97 | '*/*/edit', 98 | ['automatedexport_id' => $this->getRequest()->getParam('automatedexport_id')] 99 | ); 100 | } 101 | 102 | return $resultRedirect->setPath('*/*/listing'); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/Builder.php: -------------------------------------------------------------------------------- 1 | customReportFactory = $customReportFactory; 44 | $this->logger = $logger; 45 | $this->currentCustomReportRegistry = $currentCustomReportRegistry; 46 | $this->customReportRepository = $customReportRepository; 47 | } 48 | 49 | /** 50 | * Build custom report based on user request 51 | * 52 | * @param RequestInterface $request 53 | * 54 | * @return \DEG\CustomReports\Model\CustomReport 55 | */ 56 | public function build(RequestInterface $request): CustomReport 57 | { 58 | $customReportId = (int)$request->getParam('customreport_id'); 59 | $customReport = $this->customReportFactory->create(); 60 | if ($customReportId) { 61 | try { 62 | $customReport = $this->customReportRepository->getById($customReportId); 63 | } catch (NoSuchEntityException $e) { 64 | $this->logger->critical($e); 65 | } 66 | } 67 | 68 | $this->currentCustomReportRegistry->set($customReport); 69 | 70 | return $customReport; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/Delete.php: -------------------------------------------------------------------------------- 1 | customReportRepository = $customReportRepository; 24 | } 25 | 26 | /** 27 | * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface 28 | */ 29 | public function execute() 30 | { 31 | $id = $this->getRequest()->getParam('object_id'); 32 | $resultRedirect = $this->resultRedirectFactory->create(); 33 | if ($id) { 34 | try { 35 | $customReport = $this->customReportRepository->getById($id); 36 | $this->customReportRepository->delete($customReport); 37 | $this->messageManager->addSuccessMessage(__('You have deleted the report.')); 38 | 39 | return $resultRedirect->setPath('*/*/listing'); 40 | } catch (Exception $e) { 41 | $this->messageManager->addErrorMessage($e->getMessage()); 42 | 43 | return $resultRedirect->setPath('*/*/edit', ['customreport_id' => $id]); 44 | } 45 | } 46 | $this->messageManager->addErrorMessage(__('We can not find a report to delete.')); 47 | 48 | return $resultRedirect->setPath('*/*/listing'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/Edit.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 28 | 29 | return parent::__construct($context); 30 | } 31 | 32 | /** 33 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 34 | */ 35 | public function execute() 36 | { 37 | $resultPage = $this->resultPageFactory->create(); 38 | $resultPage->setActiveMenu('DEG_CustomReports:customreports'); 39 | $resultPage->getConfig()->getTitle()->prepend(__('Edit Report')); 40 | 41 | return $resultPage; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/ExportCsv.php: -------------------------------------------------------------------------------- 1 | fileFactory = $fileFactory; 37 | $this->builder = $builder; 38 | 39 | parent::__construct($context); 40 | } 41 | 42 | /** 43 | * Export customer grid to CSV format 44 | * 45 | * @return \Magento\Framework\App\ResponseInterface 46 | * @throws \Exception 47 | */ 48 | public function execute(): ResponseInterface 49 | { 50 | $customReport = $this->builder->build($this->getRequest()); 51 | 52 | $this->_view->loadLayout(); 53 | $fileName = $customReport->getReportName().'.csv'; 54 | 55 | /** @var @var $reportGrid \DEG\CustomReports\Block\Adminhtml\Report\Grid */ 56 | $reportGrid = $this->_view->getLayout() 57 | ->createBlock(Grid::class, 'report.grid'); 58 | /** @var Export $exportBlock */ 59 | $exportBlock = $reportGrid->getChildBlock('grid.export'); 60 | 61 | return $this->fileFactory->create( 62 | $fileName, 63 | $exportBlock->getCsvFile(), 64 | DirectoryList::VAR_DIR 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/ExportXml.php: -------------------------------------------------------------------------------- 1 | _fileFactory = $fileFactory; 37 | $this->builder = $builder; 38 | 39 | parent::__construct($context); 40 | } 41 | 42 | /** 43 | * Export customer grid to CSV format 44 | * 45 | * @return \Magento\Framework\App\ResponseInterface 46 | * @throws \Magento\Framework\Exception\FileSystemException 47 | * @throws \Exception 48 | */ 49 | public function execute(): ResponseInterface 50 | { 51 | /** @var $reportGrid \DEG\CustomReports\Block\Adminhtml\Report\Grid */ 52 | /** @var $exportBlock Export */ 53 | 54 | $customReport = $this->builder->build($this->getRequest()); 55 | $this->_view->loadLayout(); 56 | $fileName = $customReport->getReportName().'.xml'; 57 | $reportGrid = $this->_view->getLayout() 58 | ->createBlock(Grid::class, 'report.grid'); 59 | $exportBlock = $reportGrid->getChildBlock('grid.export'); 60 | 61 | return $this->_fileFactory->create( 62 | $fileName, 63 | $exportBlock->getExcelFile(), 64 | DirectoryList::VAR_DIR 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/Listing.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 29 | 30 | return parent::__construct($context); 31 | } 32 | 33 | /** 34 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 35 | */ 36 | public function execute() 37 | { 38 | $resultPage = $this->resultPageFactory->create(); 39 | $resultPage->setActiveMenu('DEG_CustomReports::customreport'); 40 | $resultPage->getConfig()->getTitle()->prepend(__('Manage Custom Reports')); 41 | 42 | return $resultPage; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/NewAction.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 28 | 29 | return parent::__construct($context); 30 | } 31 | 32 | /** 33 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 34 | */ 35 | public function execute() 36 | { 37 | $resultPage = $this->resultPageFactory->create(); 38 | $resultPage->setActiveMenu('DEG_CustomReports::customreport'); 39 | $resultPage->getConfig()->getTitle()->prepend(__('New Report')); 40 | 41 | return $resultPage; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/Report.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 36 | $this->builder = $builder; 37 | 38 | return parent::__construct($context); 39 | } 40 | 41 | /** 42 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page 43 | */ 44 | public function execute() 45 | { 46 | $customReport = $this->builder->build($this->getRequest()); 47 | $resultPage = $this->resultPageFactory->create(); 48 | $resultPage->setActiveMenu('DEG_CustomReports::customreport'); 49 | $resultPage->getConfig()->getTitle()->prepend($customReport->getReportName()); 50 | 51 | return $resultPage; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Controller/Adminhtml/CustomReport/Save.php: -------------------------------------------------------------------------------- 1 | dataPersistor = $dataPersistor; 42 | parent::__construct($context); 43 | $this->customReportRepository = $automatedExportRepository; 44 | } 45 | 46 | /** 47 | * Save action 48 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) 49 | * 50 | * @return \Magento\Framework\Controller\ResultInterface 51 | * @throws \Magento\Framework\Exception\NoSuchEntityException 52 | * @throws \Magento\Framework\Exception\NoSuchEntityException 53 | */ 54 | public function execute(): ResultInterface 55 | { 56 | $data = $this->getRequest()->getPostValue(); 57 | $resultRedirect = $this->resultRedirectFactory->create(); 58 | if ($data) { 59 | if (empty($data['customreport_id'])) { 60 | $data['customreport_id'] = null; 61 | } 62 | 63 | /** @var \DEG\CustomReports\Model\CustomReport $customReport */ 64 | $customReport = $this->_objectManager->create(CustomReport::class); 65 | 66 | $id = $this->getRequest()->getParam('customreport_id'); 67 | if ($id) { 68 | $customReport = $this->customReportRepository->getById($id); 69 | } 70 | 71 | $customReport->setData($data); 72 | 73 | try { 74 | $this->customReportRepository->save($customReport); 75 | $this->messageManager->addSuccessMessage(__('You saved the report.')); 76 | $this->dataPersistor->clear('deg_customreports_customreport'); 77 | if ($this->getRequest()->getParam('back')) { 78 | return $resultRedirect->setPath( 79 | '*/*/edit', 80 | ['customreport_id' => $customReport->getId(), '_current' => true] 81 | ); 82 | } 83 | 84 | return $resultRedirect->setPath('*/*/listing'); 85 | } catch (LocalizedException $e) { 86 | $this->messageManager->addErrorMessage($e->getMessage()); 87 | } catch (Exception $e) { 88 | $this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the data.')); 89 | } 90 | 91 | $this->dataPersistor->set('deg_customreports_customreport', $data); 92 | 93 | return $resultRedirect->setPath( 94 | '*/*/edit', 95 | ['customreport_id' => $this->getRequest()->getParam('customreport_id')] 96 | ); 97 | } 98 | 99 | return $resultRedirect->setPath('*/*/listing'); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Model/AutomatedExport.php: -------------------------------------------------------------------------------- 1 | getId()]; 41 | } 42 | 43 | protected function _construct() 44 | { 45 | $this->_init(ResourceModel\AutomatedExport::class); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Model/AutomatedExport/DataProvider.php: -------------------------------------------------------------------------------- 1 | collection = $collectionFactory->create(); 42 | $this->dataPersistor = $dataPersistor; 43 | parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); 44 | $this->meta = $this->prepareMeta($this->meta); 45 | } 46 | 47 | /** 48 | * Prepares Meta 49 | * 50 | * @param array $meta 51 | * 52 | * @return array 53 | */ 54 | public function prepareMeta(array $meta): array 55 | { 56 | return $meta; 57 | } 58 | 59 | /** 60 | * Get data 61 | * 62 | * @return array 63 | */ 64 | public function getData(): ?array 65 | { 66 | if (isset($this->loadedData)) { 67 | return $this->loadedData; 68 | } 69 | $items = $this->collection->addCustomreportIds()->getItems(); 70 | 71 | foreach ($items as $item) { 72 | $this->loadedData[$item->getId()] = $item->getData(); 73 | } 74 | 75 | $data = $this->dataPersistor->get('deg_customreports_automatedexport'); 76 | if (!empty($data)) { 77 | $item = $this->collection->getNewEmptyItem(); 78 | $item->setData($data); 79 | $this->loadedData[$item->getId()] = $item->getData(); 80 | $this->dataPersistor->clear('deg_customreports_automatedexport'); 81 | } 82 | 83 | return $this->loadedData; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Model/AutomatedExportLink.php: -------------------------------------------------------------------------------- 1 | getId()]; 31 | } 32 | 33 | protected function _construct() 34 | { 35 | $this->_init(ResourceModel\AutomatedExportLink::class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Model/Config/Source/AutomatedExports.php: -------------------------------------------------------------------------------- 1 | searchCriteriaBuilder = $searchCriteriaBuilder; 26 | $this->automatedExportRepository = $automatedExportRepository; 27 | } 28 | 29 | public function toOptionArray(): array 30 | { 31 | $searchCriteria = $this->searchCriteriaBuilder->create(); 32 | $automatedExports = $this->automatedExportRepository->getList($searchCriteria); 33 | 34 | $options = []; 35 | 36 | foreach ($automatedExports as $automatedExport) { 37 | $options[] = ['value' => $automatedExport->getId(), 'label' => $automatedExport->getName()]; 38 | } 39 | 40 | return $options; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Model/Config/Source/CustomReports.php: -------------------------------------------------------------------------------- 1 | customReportRepository = $customReportRepository; 20 | $this->searchCriteriaBuilder = $searchCriteriaBuilder; 21 | } 22 | 23 | public function toOptionArray(): array 24 | { 25 | /** @var \DEG\CustomReports\Model\CustomReport $customReport */ 26 | 27 | $searchCriteria = $this->searchCriteriaBuilder->create(); 28 | $customReports = $this->customReportRepository->getList($searchCriteria); 29 | 30 | $options = []; 31 | 32 | foreach ($customReports->getItems() as $customReport) { 33 | $options[] = ['value' => $customReport->getId(), 'label' => $customReport->getReportName()]; 34 | } 35 | 36 | return $options; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Model/Config/Source/ExportType.php: -------------------------------------------------------------------------------- 1 | 'local_file_drop', 'label' => __('Local File Drop')], 14 | ]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Model/Config/Source/FileType.php: -------------------------------------------------------------------------------- 1 | 'csv', 'label' => __('CSV')], 14 | ]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Model/CustomReport.php: -------------------------------------------------------------------------------- 1 | genericReportCollectionFactory = $genericReportCollectionFactory; 51 | } 52 | 53 | /** 54 | * @return string[] 55 | */ 56 | public function getIdentities(): array 57 | { 58 | return [self::CACHE_TAG.'_'.$this->getId()]; 59 | } 60 | 61 | /** 62 | * @return GenericReportCollection 63 | */ 64 | public function getGenericReportCollection(): GenericReportCollection 65 | { 66 | $genericReportCollection = $this->genericReportCollectionFactory->create(); 67 | $formattedSql = $this->formatSql($this->getData('report_sql')); 68 | $genericReportCollection->getSelect()->from(new Zend_Db_Expr('('.$formattedSql.')')); 69 | 70 | return $genericReportCollection; 71 | } 72 | 73 | protected function _construct() 74 | { 75 | $this->_init(ResourceModel\CustomReport::class); 76 | } 77 | 78 | /** 79 | * @param string $rawSql 80 | * 81 | * @return string 82 | */ 83 | protected function formatSql(string $rawSql): string 84 | { 85 | return trim($rawSql, ';'); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Model/CustomReport/DataProvider.php: -------------------------------------------------------------------------------- 1 | collection = $collectionFactory->create(); 42 | $this->dataPersistor = $dataPersistor; 43 | parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); 44 | $this->meta = $this->prepareMeta($this->meta); 45 | } 46 | 47 | /** 48 | * Prepares Meta 49 | * 50 | * @param array $meta 51 | * 52 | * @return array 53 | */ 54 | public function prepareMeta(array $meta): array 55 | { 56 | return $meta; 57 | } 58 | 59 | /** 60 | * Get data 61 | * 62 | * @return array 63 | */ 64 | public function getData(): ?array 65 | { 66 | if (isset($this->loadedData)) { 67 | return $this->loadedData; 68 | } 69 | $items = $this->collection->getItems(); 70 | 71 | foreach ($items as $item) { 72 | $this->loadedData[$item->getId()] = $item->getData(); 73 | } 74 | 75 | $data = $this->dataPersistor->get('deg_customreports_customreport'); 76 | if (!empty($data)) { 77 | $item = $this->collection->getNewEmptyItem(); 78 | $item->setData($data); 79 | $this->loadedData[$item->getId()] = $item->getData(); 80 | $this->dataPersistor->clear('deg_customreports_customreport'); 81 | } 82 | 83 | return $this->loadedData; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Model/GenericReportCollection.php: -------------------------------------------------------------------------------- 1 | get(ResourceConnection::class); 35 | 36 | /** 37 | * @todo: Had to remove the connectionByName = 'readonly' temporarily until readonly connection 38 | * is added to Magento Cloud Pro project by Magento Cloud support 39 | */ 40 | $connection = $resourceConnection->getConnectionByName('default'); 41 | 42 | parent::__construct($entityFactory, $logger, $fetchStrategy, $connection); 43 | } 44 | 45 | /** 46 | * Intentionally left empty since this is a generic resource. 47 | * 48 | * @noinspection PhpMissingReturnTypeInspection*/ 49 | public function getResource() 50 | { 51 | } 52 | 53 | /** 54 | * @param JoinDataInterface $join 55 | * @param JoinProcessorInterface $extensionAttributesJoinProcessor 56 | * 57 | * @return $this 58 | * @throws \Exception 59 | */ 60 | public function joinExtensionAttribute( 61 | JoinDataInterface $join, 62 | JoinProcessorInterface $extensionAttributesJoinProcessor 63 | ): GenericReportCollection { 64 | throw new Exception('joinExtensionAttribute is not allowed in GenericReportCollection'); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Model/ResourceModel/AutomatedExport/Collection.php: -------------------------------------------------------------------------------- 1 | _init(\DEG\CustomReports\Model\AutomatedExport::class, AutomatedExport::class); 14 | } 15 | 16 | public function addCustomreportIds() 17 | { 18 | $this->getSelect()->joinLeft( 19 | ['link' => $this->getTable('deg_customreports_automatedexports_link')], 20 | 'link.automatedexport_id = main_table.automatedexport_id', 21 | ['GROUP_CONCAT(link.customreport_id) as customreport_ids'] 22 | ); 23 | 24 | return $this; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Model/ResourceModel/AutomatedExportLink.php: -------------------------------------------------------------------------------- 1 | _init('deg_customreports_automatedexports_link', 'link_id'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Model/ResourceModel/AutomatedExportLink/Collection.php: -------------------------------------------------------------------------------- 1 | _init(\DEG\CustomReports\Model\AutomatedExportLink::class, AutomatedExportLink::class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Model/ResourceModel/CustomReport.php: -------------------------------------------------------------------------------- 1 | _init('deg_customreports', 'customreport_id'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Model/ResourceModel/CustomReport/Collection.php: -------------------------------------------------------------------------------- 1 | _init(\DEG\CustomReports\Model\CustomReport::class, CustomReport::class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Model/Service/CreateDynamicCron.php: -------------------------------------------------------------------------------- 1 | configValueFactory = $configValueFactory; 24 | } 25 | 26 | /** 27 | * @param \DEG\CustomReports\Api\Data\AutomatedExportInterface $automatedExport 28 | * 29 | * @throws \Exception 30 | */ 31 | public function execute(AutomatedExportInterface $automatedExport) 32 | { 33 | $automatedExportId = $automatedExport->getId(); 34 | $automatedExportModelName = 'automated_export_'.$automatedExportId; 35 | 36 | $cronStringPath = "crontab/default/jobs/$automatedExportModelName/schedule/cron_expr"; 37 | $cronModelPath = "crontab/default/jobs/$automatedExportModelName/run/model"; 38 | $cronNamePath = "crontab/default/jobs/$automatedExportModelName/name"; 39 | 40 | $this->configValueFactory->create() 41 | ->load($cronStringPath, 'path') 42 | ->setValue($automatedExport->getCronExpr()) 43 | ->setPath($cronStringPath) 44 | ->save(); 45 | $this->configValueFactory->create() 46 | ->load($cronModelPath, 'path') 47 | ->setValue(Cron::class . '::execute') 48 | ->setPath($cronModelPath) 49 | ->save(); 50 | $this->configValueFactory->create() 51 | ->load($cronNamePath, 'path') 52 | ->setValue($automatedExportModelName) 53 | ->setPath($cronNamePath) 54 | ->save(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Model/Service/DeleteDynamicCron.php: -------------------------------------------------------------------------------- 1 | configValueFactory = $configValueFactory; 22 | } 23 | 24 | /** 25 | * @param string $automatedExportModelName 26 | * 27 | * @throws \Exception 28 | */ 29 | public function execute(string $automatedExportModelName) 30 | { 31 | $cronStringPath = "crontab/default/jobs/$automatedExportModelName/schedule/cron_expr"; 32 | $cronModelPath = "crontab/default/jobs/$automatedExportModelName/run/model"; 33 | $cronNamePath = "crontab/default/jobs/$automatedExportModelName/name"; 34 | 35 | $this->configValueFactory->create() 36 | ->load($cronStringPath, 'path') 37 | ->delete(); 38 | $this->configValueFactory->create() 39 | ->load($cronModelPath, 'path') 40 | ->delete(); 41 | $this->configValueFactory->create() 42 | ->load($cronNamePath, 'path') 43 | ->delete(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEG Custom Reports 2 | 3 | This module was inspired by the Magento 1 extension for custom reports (https://github.com/kalenjordan/custom-reports). 4 | Thank you to Kalen Jordan and all who contributed to that project. 5 | 6 | ## Description 7 | 8 | Easily create reports with custom SQL queries and display them using the Magento admin grid. 9 | 10 | ## Disclaimer 11 | This module has the potential to make irreversible changes to your database if set up incorrectly. Use at your own risk. 12 | 13 | ## Features 14 | * Report result table 15 | * Usage of a read-only database connection 16 | * Column filtering 17 | * Column sorting 18 | * CSV export 19 | * Automated exports 20 | 21 | -------------------------------------------------------------------------------- /Registry/CurrentCustomReport.php: -------------------------------------------------------------------------------- 1 | currentCustomReport = $currentCustomReport; 20 | } 21 | 22 | /** 23 | * @return \DEG\CustomReports\Api\Data\CustomReportInterface|null 24 | */ 25 | public function get(): ?CustomReportInterface 26 | { 27 | return $this->currentCustomReport; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/AutomatedExport/Edit/BackButtonTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 34 | $this->url = $this->createMock(\Magento\Framework\UrlInterface::class); 35 | $this->context->method('getUrlBuilder')->willReturn($this->url); 36 | 37 | $this->backButton = new BackButton($this->context); 38 | } 39 | 40 | /** 41 | * {@inheritdoc} 42 | */ 43 | protected function tearDown(): void 44 | { 45 | parent::tearDown(); 46 | 47 | unset($this->backButton); 48 | unset($this->context); 49 | } 50 | 51 | public function testGetButtonData(): void 52 | { 53 | $testUrl = 'https//local.local/123456'; 54 | $this->url->method('getUrl')->willReturn($testUrl); 55 | 56 | $this->assertEquals(array_keys($this->backButton->getButtonData()), [ 57 | 'label', 58 | 'on_click', 59 | 'class', 60 | 'sort_order' 61 | ]); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/AutomatedExport/Edit/DeleteButtonTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 39 | $this->url = $this->createMock(\Magento\Framework\UrlInterface::class); 40 | $this->context->method('getUrlBuilder')->willReturn($this->url); 41 | 42 | $this->request = $this->createMock(RequestInterface::class); 43 | $this->context->method('getRequest')->willReturn($this->request); 44 | 45 | $this->deleteButton = new DeleteButton($this->context); 46 | } 47 | 48 | /** 49 | * {@inheritdoc} 50 | */ 51 | protected function tearDown(): void 52 | { 53 | parent::tearDown(); 54 | unset($this->deleteButton); 55 | unset($this->url); 56 | } 57 | 58 | public function testGetButtonData(): void 59 | { 60 | $this->request->method('getParam')->with('automatedexport_id')->willReturn('1'); 61 | $testUrl = 'https//local.local/123456'; 62 | $this->url->method('getUrl')->willReturn($testUrl); 63 | 64 | $this->assertEquals(array_keys($this->deleteButton->getButtonData()), [ 65 | 'label', 66 | 'class', 67 | 'on_click', 68 | 'sort_order' 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/AutomatedExport/Edit/ResetButtonTest.php: -------------------------------------------------------------------------------- 1 | block = $objectManager->getObject( 16 | 'DEG\CustomReports\Block\Adminhtml\AutomatedExport\Edit\ResetButton' 17 | ); 18 | } 19 | 20 | public function testGetButtonData(): void 21 | { 22 | $this->assertEquals($this->block->getButtonData(), [ 23 | 'label' => __('Reset'), 24 | 'class' => 'reset', 25 | 'on_click' => 'location.reload();', 26 | 'sort_order' => 30 27 | ]); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/AutomatedExport/Edit/SaveAndContinueButtonTest.php: -------------------------------------------------------------------------------- 1 | block = $objectManager->getObject( 15 | 'DEG\CustomReports\Block\Adminhtml\AutomatedExport\Edit\SaveAndContinueButton' 16 | ); 17 | } 18 | 19 | public function testGetButtonData(): void 20 | { 21 | $this->assertEquals($this->block->getButtonData(), [ 22 | 'label' => __('Save and Continue Edit'), 23 | 'class' => 'save', 24 | 'data_attribute' => [ 25 | 'mage-init' => [ 26 | 'button' => ['event' => 'saveAndContinueEdit'], 27 | ], 28 | ], 29 | 'sort_order' => 80, 30 | ]); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/AutomatedExport/Edit/SaveButtonTest.php: -------------------------------------------------------------------------------- 1 | block = $objectManager->getObject( 15 | 'DEG\CustomReports\Block\Adminhtml\AutomatedExport\Edit\SaveButton' 16 | ); 17 | } 18 | 19 | public function testGetButtonData(): void 20 | { 21 | $this->assertEquals($this->block->getButtonData(), [ 22 | 'label' => __('Save Report'), 23 | 'class' => 'save primary', 24 | 'data_attribute' => [ 25 | 'mage-init' => ['button' => ['event' => 'save']], 26 | 'form-role' => 'save', 27 | ], 28 | 'sort_order' => 90, 29 | ]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/CustomReport/Edit/BackButtonTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 34 | $this->url = $this->createMock(\Magento\Framework\UrlInterface::class); 35 | $this->context->method('getUrlBuilder')->willReturn($this->url); 36 | 37 | $this->backButton = new BackButton($this->context); 38 | } 39 | 40 | /** 41 | * {@inheritdoc} 42 | */ 43 | protected function tearDown(): void 44 | { 45 | parent::tearDown(); 46 | 47 | unset($this->backButton); 48 | unset($this->context); 49 | } 50 | 51 | public function testGetButtonData(): void 52 | { 53 | $testUrl = 'https//local.local/123456'; 54 | $this->url->method('getUrl')->willReturn($testUrl); 55 | 56 | $this->assertEquals(array_keys($this->backButton->getButtonData()), [ 57 | 'label', 58 | 'on_click', 59 | 'class', 60 | 'sort_order' 61 | ]); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/CustomReport/Edit/DeleteButtonTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 39 | $this->url = $this->createMock(\Magento\Framework\UrlInterface::class); 40 | $this->context->method('getUrlBuilder')->willReturn($this->url); 41 | 42 | $this->request = $this->createMock(RequestInterface::class); 43 | $this->context->method('getRequest')->willReturn($this->request); 44 | 45 | $this->deleteButton = new DeleteButton($this->context); 46 | } 47 | 48 | /** 49 | * {@inheritdoc} 50 | */ 51 | protected function tearDown(): void 52 | { 53 | parent::tearDown(); 54 | unset($this->deleteButton); 55 | unset($this->url); 56 | } 57 | 58 | public function testGetButtonData(): void 59 | { 60 | $this->request->method('getParam')->with('customreport_id')->willReturn('1'); 61 | $testUrl = 'https//local.local/123456'; 62 | $this->url->method('getUrl')->willReturn($testUrl); 63 | 64 | $this->assertEquals(array_keys($this->deleteButton->getButtonData()), [ 65 | 'label', 66 | 'class', 67 | 'on_click', 68 | 'sort_order' 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/CustomReport/Edit/ResetButtonTest.php: -------------------------------------------------------------------------------- 1 | block = $objectManager->getObject( 15 | 'DEG\CustomReports\Block\Adminhtml\CustomReport\Edit\ResetButton' 16 | ); 17 | } 18 | 19 | public function testGetButtonData(): void 20 | { 21 | $this->assertEquals($this->block->getButtonData(), [ 22 | 'label' => __('Reset'), 23 | 'class' => 'reset', 24 | 'on_click' => 'location.reload();', 25 | 'sort_order' => 30 26 | ]); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/CustomReport/Edit/SaveAndContinueButtonTest.php: -------------------------------------------------------------------------------- 1 | block = $objectManager->getObject( 15 | 'DEG\CustomReports\Block\Adminhtml\CustomReport\Edit\SaveAndContinueButton' 16 | ); 17 | } 18 | 19 | public function testGetButtonData(): void 20 | { 21 | $this->assertEquals($this->block->getButtonData(), [ 22 | 'label' => __('Save and Continue Edit'), 23 | 'class' => 'save', 24 | 'data_attribute' => [ 25 | 'mage-init' => [ 26 | 'button' => ['event' => 'saveAndContinueEdit'], 27 | ], 28 | ], 29 | 'sort_order' => 80, 30 | ]); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/CustomReport/Edit/SaveButtonTest.php: -------------------------------------------------------------------------------- 1 | block = $objectManager->getObject( 15 | 'DEG\CustomReports\Block\Adminhtml\CustomReport\Edit\SaveButton' 16 | ); 17 | } 18 | 19 | public function testGetButtonData(): void 20 | { 21 | $this->assertEquals($this->block->getButtonData(), [ 22 | 'label' => __('Save Report'), 23 | 'class' => 'save primary', 24 | 'data_attribute' => [ 25 | 'mage-init' => ['button' => ['event' => 'save']], 26 | 'form-role' => 'save', 27 | ], 28 | 'sort_order' => 90, 29 | ]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Test/Unit/Block/Adminhtml/Report/ReportTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 57 | 58 | $this->fileSystem = $this->createMock(\Magento\Framework\Filesystem::class); 59 | $this->context->method('getFilesystem')->willReturn($this->fileSystem); 60 | 61 | $this->layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); 62 | $this->context->method('getLayout')->willReturn($this->layout); 63 | 64 | $this->collectionFactory = $this->createMock(CollectionFactory::class); 65 | $this->timeZone = $this->createMock(TimezoneInterface::class); 66 | $this->data = []; 67 | $this->export = new Export($this->context, $this->collectionFactory, $this->timeZone, $this->data); 68 | } 69 | 70 | /** 71 | * {@inheritdoc} 72 | */ 73 | protected function tearDown(): void 74 | { 75 | parent::tearDown(); 76 | 77 | unset($this->export); 78 | unset($this->context); 79 | unset($this->collectionFactory); 80 | unset($this->timeZone); 81 | unset($this->data); 82 | } 83 | 84 | public function test_prepareLayout(): void 85 | { 86 | $this->export->_prepareLayout(); 87 | } 88 | 89 | public function testLazyPrepareLayout(): void 90 | { 91 | $blockMock = $this->createMock(\Magento\Framework\View\Element\Template::class); 92 | $this->layout->method('createBlock')->willReturn($blockMock); 93 | 94 | $this->layout->method('getParentName')->willReturn('testBlock'); 95 | $abstractBlockMock = $this->createMock(\Magento\Framework\View\Element\AbstractBlock::class); 96 | $this->layout->method('getBlock')->willReturn($abstractBlockMock); 97 | 98 | $this->export->lazyPrepareLayout(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/DeleteTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 51 | $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); 52 | $this->context->method('getRequest')->willReturn($this->requestMock); 53 | 54 | $this->redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\RedirectFactory::class); 55 | $this->context->method('getResultRedirectFactory')->willReturn($this->redirectPageMock); 56 | 57 | $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); 58 | $this->context->method('getMessageManager')->willReturn($this->messageManagerMock); 59 | 60 | $this->customReportRepository = $this->createMock(CustomReportRepositoryInterface::class); 61 | $this->delete = new Delete($this->context, $this->customReportRepository); 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | protected function tearDown(): void 68 | { 69 | parent::tearDown(); 70 | 71 | unset($this->delete); 72 | unset($this->context); 73 | unset($this->customReportRepository); 74 | } 75 | 76 | public function testExecuteIdUndefined(): void 77 | { 78 | $this->requestMock->method('getParam') 79 | ->with('object_id')->willReturn(null); 80 | 81 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 82 | $this->redirectPageMock->method('create') 83 | ->willReturn($redirectPageMock); 84 | 85 | $this->delete->execute(); 86 | } 87 | 88 | public function testExecute(): void 89 | { 90 | $this->requestMock->method('getParam') 91 | ->with('object_id')->willReturn(1); 92 | 93 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 94 | $this->redirectPageMock->method('create') 95 | ->willReturn($redirectPageMock); 96 | 97 | 98 | $this->delete->execute(); 99 | } 100 | 101 | public function testExecuteFailed(): void 102 | { 103 | $this->requestMock->method('getParam') 104 | ->with('object_id')->willReturn(1); 105 | 106 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 107 | $this->redirectPageMock->method('create') 108 | ->willReturn($redirectPageMock); 109 | 110 | $this->customReportRepository->method('delete') 111 | ->willThrowException(new \Exception('test failed deleted')); 112 | 113 | $this->delete->execute(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/EditTest.php: -------------------------------------------------------------------------------- 1 | titleMock = $this->getMockTitle(); 23 | $this->resultPageFactory = $this->getResultPageFactory(); 24 | 25 | $this->contextMock = $this->createMock(Context::class); 26 | 27 | } 28 | 29 | protected function getResultPageFactory() 30 | { 31 | $mockPageResult = $this 32 | ->getMockBuilder(PageFactory::class) 33 | ->disableOriginalConstructor() 34 | ->setMethods(['create']) 35 | ->getMockForAbstractClass(); 36 | 37 | $mockPage = $this 38 | ->getMockBuilder(\Magento\Framework\View\Result\Page::class) 39 | ->disableOriginalConstructor() 40 | ->setMethods(['setActiveMenu', 'getConfig']) 41 | ->getMockForAbstractClass(); 42 | 43 | 44 | $mockConfig = $this 45 | ->getMockBuilder(\Magento\Framework\View\Page\Config::class) 46 | ->disableOriginalConstructor() 47 | ->setMethods(['getTitle']) 48 | ->getMockForAbstractClass(); 49 | 50 | 51 | $mockPageResult->expects($this->any()) 52 | ->method('create') 53 | ->willReturn($mockPage); 54 | 55 | $mockPage->expects($this->any()) 56 | ->method('getConfig') 57 | ->willReturn($mockConfig); 58 | 59 | $mockConfig->expects($this->any()) 60 | ->method('getTitle') 61 | ->willReturn($this->titleMock); 62 | 63 | return $mockPageResult; 64 | } 65 | 66 | protected function getMockTitle() 67 | { 68 | $mockTitle = $this 69 | ->getMockBuilder(\Magento\Framework\View\Page\Title::class) 70 | ->disableOriginalConstructor() 71 | ->setMethods(['prepend']) 72 | ->getMockForAbstractClass(); 73 | 74 | return $mockTitle; 75 | } 76 | 77 | protected function getModel() 78 | { 79 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 80 | 81 | $model = $objectManager->getObject( 82 | \DEG\CustomReports\Controller\Adminhtml\AutomatedExport\Edit::class, 83 | [ 84 | "context" => $this->contextMock, 85 | "resultPageFactory" => $this->resultPageFactory, 86 | ] 87 | ); 88 | 89 | return $model; 90 | } 91 | 92 | public function testExecuteExeptionType(): void 93 | { 94 | 95 | $this->titleMock->expects($this->at(0)) 96 | ->method('prepend') 97 | ->willReturn(__('New Report')); 98 | 99 | $this->getModel()->execute(); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/ExportCsvTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 59 | $this->requestMock = $this->createMock(RequestInterface::class); 60 | $this->context->method('getRequest')->willReturn($this->requestMock); 61 | 62 | $this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class); 63 | $this->context->method('getView')->willReturn($this->viewMock); 64 | 65 | $this->layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class); 66 | $this->viewMock->method('getLayout')->willReturn($this->layoutMock); 67 | 68 | $this->fileFactory = $this->createMock(FileFactory::class); 69 | $this->builder = $this->createMock(Builder::class); 70 | $this->exportCsv = new ExportCsv($this->context, $this->fileFactory, $this->builder); 71 | } 72 | 73 | /** 74 | * {@inheritdoc} 75 | */ 76 | protected function tearDown(): void 77 | { 78 | parent::tearDown(); 79 | 80 | unset($this->exportCsv); 81 | unset($this->context); 82 | unset($this->fileFactory); 83 | unset($this->builder); 84 | } 85 | 86 | public function testExecute(): void 87 | { 88 | $blockMock = $this->createMock(AbstractBlock::class); 89 | $this->layoutMock->method('createBlock')->willReturn($blockMock); 90 | 91 | $blockExport = $this->createMock(\DEG\CustomReports\Block\Adminhtml\Report\Export::class); 92 | $blockMock->method('getChildBlock')->willReturn($blockExport); 93 | 94 | $responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); 95 | $this->fileFactory->method('create')->willReturn($responseMock); 96 | 97 | $this->exportCsv->execute(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/ExportXmlTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 58 | $this->requestMock = $this->createMock(RequestInterface::class); 59 | $this->context->method('getRequest')->willReturn($this->requestMock); 60 | 61 | $this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class); 62 | $this->context->method('getView')->willReturn($this->viewMock); 63 | 64 | $this->layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class); 65 | $this->viewMock->method('getLayout')->willReturn($this->layoutMock); 66 | 67 | $this->fileFactory = $this->createMock(FileFactory::class); 68 | $this->builder = $this->createMock(Builder::class); 69 | $this->exportXml = new ExportXml($this->context, $this->fileFactory, $this->builder); 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | protected function tearDown(): void 76 | { 77 | parent::tearDown(); 78 | 79 | unset($this->exportXml); 80 | unset($this->context); 81 | unset($this->fileFactory); 82 | unset($this->builder); 83 | } 84 | 85 | public function testExecute(): void 86 | { 87 | $blockMock = $this->createMock(AbstractBlock::class); 88 | $this->layoutMock->method('createBlock')->willReturn($blockMock); 89 | 90 | $blockExport = $this->createMock(\DEG\CustomReports\Block\Adminhtml\Report\Export::class); 91 | $blockMock->method('getChildBlock')->willReturn($blockExport); 92 | 93 | $responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); 94 | $this->fileFactory->method('create')->willReturn($responseMock); 95 | 96 | $this->exportXml->execute(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/ListingTest.php: -------------------------------------------------------------------------------- 1 | titleMock = $this->getMockTitle(); 22 | $this->resultPageFactory = $this->getResultPageFactory(); 23 | 24 | $this->contextMock = $this->createMock(Context::class); 25 | 26 | } 27 | 28 | protected function getResultPageFactory() 29 | { 30 | $mockPageResult = $this 31 | ->getMockBuilder(PageFactory::class) 32 | ->disableOriginalConstructor() 33 | ->setMethods(['create']) 34 | ->getMockForAbstractClass(); 35 | 36 | $mockPage = $this 37 | ->getMockBuilder(\Magento\Framework\View\Result\Page::class) 38 | ->disableOriginalConstructor() 39 | ->setMethods(['setActiveMenu', 'getConfig']) 40 | ->getMockForAbstractClass(); 41 | 42 | 43 | $mockConfig = $this 44 | ->getMockBuilder(\Magento\Framework\View\Page\Config::class) 45 | ->disableOriginalConstructor() 46 | ->setMethods(['getTitle']) 47 | ->getMockForAbstractClass(); 48 | 49 | 50 | $mockPageResult->expects($this->any()) 51 | ->method('create') 52 | ->willReturn($mockPage); 53 | 54 | $mockPage->expects($this->any()) 55 | ->method('getConfig') 56 | ->willReturn($mockConfig); 57 | 58 | $mockConfig->expects($this->any()) 59 | ->method('getTitle') 60 | ->willReturn($this->titleMock); 61 | 62 | return $mockPageResult; 63 | } 64 | 65 | protected function getMockTitle() 66 | { 67 | $mockTitle = $this 68 | ->getMockBuilder(\Magento\Framework\View\Page\Title::class) 69 | ->disableOriginalConstructor() 70 | ->setMethods(['prepend']) 71 | ->getMockForAbstractClass(); 72 | 73 | return $mockTitle; 74 | } 75 | 76 | protected function getModel() 77 | { 78 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 79 | 80 | $model = $objectManager->getObject( 81 | \DEG\CustomReports\Controller\Adminhtml\AutomatedExport\Listing::class, 82 | [ 83 | "context" => $this->contextMock, 84 | "resultPageFactory" => $this->resultPageFactory, 85 | ] 86 | ); 87 | 88 | return $model; 89 | } 90 | 91 | public function testExecuteExeptionType(): void 92 | { 93 | $this->titleMock->expects($this->at(0)) 94 | ->method('prepend') 95 | ->willReturn(__('New Report')); 96 | 97 | $this->getModel()->execute(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/NewActionTest.php: -------------------------------------------------------------------------------- 1 | titleMock = $this->getMockTitle(); 22 | $this->resultPageFactory = $this->getResultPageFactory(); 23 | 24 | $this->contextMock = $this->createMock(Context::class); 25 | 26 | } 27 | 28 | protected function getResultPageFactory() 29 | { 30 | $mockPageResult = $this 31 | ->getMockBuilder(PageFactory::class) 32 | ->disableOriginalConstructor() 33 | ->setMethods(['create']) 34 | ->getMockForAbstractClass(); 35 | 36 | $mockPage = $this 37 | ->getMockBuilder(\Magento\Framework\View\Result\Page::class) 38 | ->disableOriginalConstructor() 39 | ->setMethods(['setActiveMenu', 'getConfig']) 40 | ->getMockForAbstractClass(); 41 | 42 | 43 | $mockConfig = $this 44 | ->getMockBuilder(\Magento\Framework\View\Page\Config::class) 45 | ->disableOriginalConstructor() 46 | ->setMethods(['getTitle']) 47 | ->getMockForAbstractClass(); 48 | 49 | 50 | $mockPageResult->expects($this->any()) 51 | ->method('create') 52 | ->willReturn($mockPage); 53 | 54 | $mockPage->expects($this->any()) 55 | ->method('getConfig') 56 | ->willReturn($mockConfig); 57 | 58 | $mockConfig->expects($this->any()) 59 | ->method('getTitle') 60 | ->willReturn($this->titleMock); 61 | 62 | return $mockPageResult; 63 | } 64 | 65 | protected function getMockTitle() 66 | { 67 | $mockTitle = $this 68 | ->getMockBuilder(\Magento\Framework\View\Page\Title::class) 69 | ->disableOriginalConstructor() 70 | ->setMethods(['prepend']) 71 | ->getMockForAbstractClass(); 72 | 73 | return $mockTitle; 74 | } 75 | 76 | protected function getModel() 77 | { 78 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 79 | 80 | $model = $objectManager->getObject( 81 | \DEG\CustomReports\Controller\Adminhtml\AutomatedExport\NewAction::class, 82 | [ 83 | "context" => $this->contextMock, 84 | "resultPageFactory" => $this->resultPageFactory, 85 | ] 86 | ); 87 | 88 | return $model; 89 | } 90 | 91 | public function testExecuteExeptionType(): void 92 | { 93 | $this->titleMock->expects($this->at(0)) 94 | ->method('prepend') 95 | ->willReturn(__('New Report')); 96 | 97 | $this->getModel()->execute(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/ReportTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 47 | $this->requestMock = $this->createMock(RequestInterface::class); 48 | $this->context->method('getRequest')->willReturn($this->requestMock); 49 | 50 | $this->resultPageFactory = $this->createMock(PageFactory::class); 51 | $this->builder = $this->createMock(Builder::class); 52 | $this->report = new Report($this->context, $this->resultPageFactory, $this->builder); 53 | } 54 | 55 | /** 56 | * {@inheritdoc} 57 | */ 58 | protected function tearDown(): void 59 | { 60 | parent::tearDown(); 61 | 62 | unset($this->report); 63 | unset($this->context); 64 | unset($this->resultPageFactory); 65 | unset($this->builder); 66 | } 67 | 68 | public function testExecute(): void 69 | { 70 | $pageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) 71 | ->setMethods(['setActiveMenu', 'getConfig']) 72 | ->disableOriginalConstructor() 73 | ->getMock(); 74 | $this->resultPageFactory->method('create')->willReturn($pageMock); 75 | 76 | $configMock = $this->createMock(\Magento\Framework\View\Page\Config::class); 77 | $pageMock->method('getConfig')->willReturn($configMock); 78 | 79 | $titleMock = $this->createMock(\Magento\Framework\View\Page\Title::class); 80 | $configMock->method('getTitle')->willReturn($titleMock); 81 | 82 | $this->report->execute(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/AutomatedExport/SaveTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 68 | $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); 69 | $this->context->method('getRequest')->willReturn($this->requestMock); 70 | 71 | $this->redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\RedirectFactory::class); 72 | $this->context->method('getResultRedirectFactory')->willReturn($this->redirectPageMock); 73 | 74 | $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); 75 | $this->context->method('getObjectManager')->willReturn($this->objectManagerMock); 76 | 77 | $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); 78 | $this->context->method('getMessageManager')->willReturn($this->messageManagerMock); 79 | 80 | $this->dataPersistor = $this->createMock(DataPersistorInterface::class); 81 | $this->automatedExportRepository = $this->createMock(\DEG\CustomReports\Api\AutomatedExportRepositoryInterface::class); 82 | $this->automatedExportFactory = $this->createMock(AutomatedExportInterfaceFactory::class); 83 | $this->save = new Save($this->context, $this->dataPersistor, $this->automatedExportRepository, $this->automatedExportFactory); 84 | } 85 | 86 | /** 87 | * {@inheritdoc} 88 | */ 89 | protected function tearDown(): void 90 | { 91 | parent::tearDown(); 92 | 93 | unset($this->save); 94 | unset($this->context); 95 | unset($this->dataPersistor); 96 | unset($this->automatedExportRepository); 97 | } 98 | 99 | public function testExecute(): void 100 | { 101 | $data = [ 102 | 'customreport_id' => 1 103 | ]; 104 | $this->requestMock->method('getPostValue')->willReturn($data); 105 | 106 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 107 | $this->redirectPageMock->method('create')->willReturn($redirectPageMock); 108 | 109 | $customReportMock = $this->createMock(\DEG\CustomReports\Model\AutomatedExport::class); 110 | $this->automatedExportFactory->method('create')->willReturn($customReportMock); 111 | 112 | $redirectPageMock->method('setPath')->willReturnSelf(); 113 | 114 | $this->save->execute(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/BuilderTest.php: -------------------------------------------------------------------------------- 1 | customReport = $this->getCustomReport(); 42 | $this->customReportFactory = $this->getCustomReportFactory(); 43 | $this->logger = $this->getLogger(); 44 | $this->registry = $this->getRegistry(); 45 | $this->requestMock = $this->getMockForAbstractClass( 46 | \Magento\Framework\App\RequestInterface::class, 47 | [], 48 | '', 49 | false, 50 | true, 51 | true, 52 | ['getParam'] 53 | ); 54 | } 55 | 56 | protected function getCustomReportFactory() 57 | { 58 | $mockHelper = $this 59 | ->getMockBuilder(CustomReportFactory::class) 60 | ->disableOriginalConstructor() 61 | ->setMethods(['create']) 62 | ->getMock(); 63 | 64 | $mockHelper->expects($this->any()) 65 | ->method('create') 66 | ->willReturn($this->customReport); 67 | 68 | return $mockHelper; 69 | } 70 | 71 | protected function getLogger() 72 | { 73 | $mockHelper = $this 74 | ->getMockBuilder(Logger::class) 75 | ->disableOriginalConstructor() 76 | ->setMethods(['critical']) 77 | ->getMockForAbstractClass(); 78 | 79 | return $mockHelper; 80 | } 81 | 82 | protected function getRegistry() 83 | { 84 | $mockHelper = $this 85 | ->getMockBuilder(Registry::class) 86 | ->disableOriginalConstructor() 87 | ->setMethods(['register']) 88 | ->getMockForAbstractClass(); 89 | 90 | return $mockHelper; 91 | } 92 | 93 | protected function getCustomReport() 94 | { 95 | $mockHelper = $this 96 | ->getMockBuilder(\DEG\CustomReports\Model\CustomReport::class) 97 | ->disableOriginalConstructor() 98 | ->setMethods(['load']) 99 | ->getMockForAbstractClass(); 100 | 101 | return $mockHelper; 102 | } 103 | 104 | 105 | protected function getModel() 106 | { 107 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 108 | 109 | $model = $objectManager->getObject( 110 | \DEG\CustomReports\Controller\Adminhtml\CustomReport\Builder::class, 111 | [ 112 | "customReportFactory" => $this->customReportFactory, 113 | "logger" => $this->logger, 114 | "registry" => $this->registry 115 | ] 116 | ); 117 | 118 | return $model; 119 | } 120 | 121 | public function testBuild(): void 122 | { 123 | $this->requestMock 124 | ->expects($this->at(0)) 125 | ->method('getParam') 126 | ->willReturn(122); 127 | 128 | $this->getModel()->build($this->requestMock); 129 | } 130 | 131 | 132 | public function testBuildNullId(): void 133 | { 134 | $this->requestMock 135 | ->expects($this->at(0)) 136 | ->method('getParam') 137 | ->willReturn(null); 138 | 139 | $this->getModel()->build($this->requestMock); 140 | } 141 | 142 | 143 | public function testBuildLogger(): void 144 | { 145 | $this->requestMock 146 | ->expects($this->at(0)) 147 | ->method('getParam') 148 | ->willReturn(10); 149 | 150 | $this->getModel()->build($this->requestMock); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/DeleteTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 51 | $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); 52 | $this->context->method('getRequest')->willReturn($this->requestMock); 53 | 54 | $this->redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\RedirectFactory::class); 55 | $this->context->method('getResultRedirectFactory')->willReturn($this->redirectPageMock); 56 | 57 | $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); 58 | $this->context->method('getMessageManager')->willReturn($this->messageManagerMock); 59 | 60 | $this->customReportRepository = $this->createMock(CustomReportRepositoryInterface::class); 61 | $this->delete = new Delete($this->context, $this->customReportRepository); 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | protected function tearDown(): void 68 | { 69 | parent::tearDown(); 70 | 71 | unset($this->delete); 72 | unset($this->context); 73 | unset($this->customReportRepository); 74 | } 75 | 76 | public function testExecuteIdUndefined(): void 77 | { 78 | $this->requestMock->method('getParam') 79 | ->with('object_id')->willReturn(null); 80 | 81 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 82 | $this->redirectPageMock->method('create') 83 | ->willReturn($redirectPageMock); 84 | 85 | $this->delete->execute(); 86 | } 87 | 88 | public function testExecute(): void 89 | { 90 | $this->requestMock->method('getParam') 91 | ->with('object_id')->willReturn(1); 92 | 93 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 94 | $this->redirectPageMock->method('create') 95 | ->willReturn($redirectPageMock); 96 | 97 | 98 | $this->delete->execute(); 99 | } 100 | 101 | public function testExecuteFailed(): void 102 | { 103 | $this->requestMock->method('getParam') 104 | ->with('object_id')->willReturn(1); 105 | 106 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 107 | $this->redirectPageMock->method('create') 108 | ->willReturn($redirectPageMock); 109 | 110 | $this->customReportRepository->method('delete') 111 | ->willThrowException(new \Exception('test failed deleted')); 112 | 113 | $this->delete->execute(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/EditTest.php: -------------------------------------------------------------------------------- 1 | titleMock = $this->getMockTitle(); 23 | $this->resultPageFactory = $this->getResultPageFactory(); 24 | 25 | $this->contextMock = $this->createMock(Context::class); 26 | 27 | } 28 | 29 | protected function getResultPageFactory() 30 | { 31 | $mockPageResult = $this 32 | ->getMockBuilder(PageFactory::class) 33 | ->disableOriginalConstructor() 34 | ->setMethods(['create']) 35 | ->getMockForAbstractClass(); 36 | 37 | $mockPage = $this 38 | ->getMockBuilder(\Magento\Framework\View\Result\Page::class) 39 | ->disableOriginalConstructor() 40 | ->setMethods(['setActiveMenu', 'getConfig']) 41 | ->getMockForAbstractClass(); 42 | 43 | 44 | $mockConfig = $this 45 | ->getMockBuilder(\Magento\Framework\View\Page\Config::class) 46 | ->disableOriginalConstructor() 47 | ->setMethods(['getTitle']) 48 | ->getMockForAbstractClass(); 49 | 50 | 51 | $mockPageResult->expects($this->any()) 52 | ->method('create') 53 | ->willReturn($mockPage); 54 | 55 | $mockPage->expects($this->any()) 56 | ->method('getConfig') 57 | ->willReturn($mockConfig); 58 | 59 | $mockConfig->expects($this->any()) 60 | ->method('getTitle') 61 | ->willReturn($this->titleMock); 62 | 63 | return $mockPageResult; 64 | } 65 | 66 | protected function getMockTitle() 67 | { 68 | $mockTitle = $this 69 | ->getMockBuilder(\Magento\Framework\View\Page\Title::class) 70 | ->disableOriginalConstructor() 71 | ->setMethods(['prepend']) 72 | ->getMockForAbstractClass(); 73 | 74 | return $mockTitle; 75 | } 76 | 77 | protected function getModel() 78 | { 79 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 80 | 81 | $model = $objectManager->getObject( 82 | \DEG\CustomReports\Controller\Adminhtml\CustomReport\Edit::class, 83 | [ 84 | "context" => $this->contextMock, 85 | "resultPageFactory" => $this->resultPageFactory, 86 | ] 87 | ); 88 | 89 | return $model; 90 | } 91 | 92 | public function testExecuteExeptionType(): void 93 | { 94 | 95 | $this->titleMock->expects($this->at(0)) 96 | ->method('prepend') 97 | ->willReturn(__('New Report')); 98 | 99 | $this->getModel()->execute(); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/ExportCsvTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 59 | $this->requestMock = $this->createMock(RequestInterface::class); 60 | $this->context->method('getRequest')->willReturn($this->requestMock); 61 | 62 | $this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class); 63 | $this->context->method('getView')->willReturn($this->viewMock); 64 | 65 | $this->layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class); 66 | $this->viewMock->method('getLayout')->willReturn($this->layoutMock); 67 | 68 | $this->fileFactory = $this->createMock(FileFactory::class); 69 | $this->builder = $this->createMock(Builder::class); 70 | $this->exportCsv = new ExportCsv($this->context, $this->fileFactory, $this->builder); 71 | } 72 | 73 | /** 74 | * {@inheritdoc} 75 | */ 76 | protected function tearDown(): void 77 | { 78 | parent::tearDown(); 79 | 80 | unset($this->exportCsv); 81 | unset($this->context); 82 | unset($this->fileFactory); 83 | unset($this->builder); 84 | } 85 | 86 | public function testExecute(): void 87 | { 88 | $blockMock = $this->createMock(AbstractBlock::class); 89 | $this->layoutMock->method('createBlock')->willReturn($blockMock); 90 | 91 | $blockExport = $this->createMock(\DEG\CustomReports\Block\Adminhtml\Report\Export::class); 92 | $blockMock->method('getChildBlock')->willReturn($blockExport); 93 | 94 | $responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); 95 | $this->fileFactory->method('create')->willReturn($responseMock); 96 | 97 | $this->exportCsv->execute(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/ExportXmlTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 58 | $this->requestMock = $this->createMock(RequestInterface::class); 59 | $this->context->method('getRequest')->willReturn($this->requestMock); 60 | 61 | $this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class); 62 | $this->context->method('getView')->willReturn($this->viewMock); 63 | 64 | $this->layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class); 65 | $this->viewMock->method('getLayout')->willReturn($this->layoutMock); 66 | 67 | $this->fileFactory = $this->createMock(FileFactory::class); 68 | $this->builder = $this->createMock(Builder::class); 69 | $this->exportXml = new ExportXml($this->context, $this->fileFactory, $this->builder); 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | protected function tearDown(): void 76 | { 77 | parent::tearDown(); 78 | 79 | unset($this->exportXml); 80 | unset($this->context); 81 | unset($this->fileFactory); 82 | unset($this->builder); 83 | } 84 | 85 | public function testExecute(): void 86 | { 87 | $blockMock = $this->createMock(AbstractBlock::class); 88 | $this->layoutMock->method('createBlock')->willReturn($blockMock); 89 | 90 | $blockExport = $this->createMock(\DEG\CustomReports\Block\Adminhtml\Report\Export::class); 91 | $blockMock->method('getChildBlock')->willReturn($blockExport); 92 | 93 | $responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); 94 | $this->fileFactory->method('create')->willReturn($responseMock); 95 | 96 | $this->exportXml->execute(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/ListingTest.php: -------------------------------------------------------------------------------- 1 | titleMock = $this->getMockTitle(); 22 | $this->resultPageFactory = $this->getResultPageFactory(); 23 | 24 | $this->contextMock = $this->createMock(Context::class); 25 | 26 | } 27 | 28 | protected function getResultPageFactory() 29 | { 30 | $mockPageResult = $this 31 | ->getMockBuilder(PageFactory::class) 32 | ->disableOriginalConstructor() 33 | ->setMethods(['create']) 34 | ->getMockForAbstractClass(); 35 | 36 | $mockPage = $this 37 | ->getMockBuilder(\Magento\Framework\View\Result\Page::class) 38 | ->disableOriginalConstructor() 39 | ->setMethods(['setActiveMenu', 'getConfig']) 40 | ->getMockForAbstractClass(); 41 | 42 | 43 | $mockConfig = $this 44 | ->getMockBuilder(\Magento\Framework\View\Page\Config::class) 45 | ->disableOriginalConstructor() 46 | ->setMethods(['getTitle']) 47 | ->getMockForAbstractClass(); 48 | 49 | 50 | $mockPageResult->expects($this->any()) 51 | ->method('create') 52 | ->willReturn($mockPage); 53 | 54 | $mockPage->expects($this->any()) 55 | ->method('getConfig') 56 | ->willReturn($mockConfig); 57 | 58 | $mockConfig->expects($this->any()) 59 | ->method('getTitle') 60 | ->willReturn($this->titleMock); 61 | 62 | return $mockPageResult; 63 | } 64 | 65 | protected function getMockTitle() 66 | { 67 | $mockTitle = $this 68 | ->getMockBuilder(\Magento\Framework\View\Page\Title::class) 69 | ->disableOriginalConstructor() 70 | ->setMethods(['prepend']) 71 | ->getMockForAbstractClass(); 72 | 73 | return $mockTitle; 74 | } 75 | 76 | protected function getModel() 77 | { 78 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 79 | 80 | $model = $objectManager->getObject( 81 | \DEG\CustomReports\Controller\Adminhtml\CustomReport\Listing::class, 82 | [ 83 | "context" => $this->contextMock, 84 | "resultPageFactory" => $this->resultPageFactory, 85 | ] 86 | ); 87 | 88 | return $model; 89 | } 90 | 91 | public function testExecuteExeptionType(): void 92 | { 93 | $this->titleMock->expects($this->at(0)) 94 | ->method('prepend') 95 | ->willReturn(__('New Report')); 96 | 97 | $this->getModel()->execute(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/NewActionTest.php: -------------------------------------------------------------------------------- 1 | titleMock = $this->getMockTitle(); 22 | $this->resultPageFactory = $this->getResultPageFactory(); 23 | 24 | $this->contextMock = $this->createMock(Context::class); 25 | 26 | } 27 | 28 | protected function getResultPageFactory() 29 | { 30 | $mockPageResult = $this 31 | ->getMockBuilder(PageFactory::class) 32 | ->disableOriginalConstructor() 33 | ->setMethods(['create']) 34 | ->getMockForAbstractClass(); 35 | 36 | $mockPage = $this 37 | ->getMockBuilder(\Magento\Framework\View\Result\Page::class) 38 | ->disableOriginalConstructor() 39 | ->setMethods(['setActiveMenu', 'getConfig']) 40 | ->getMockForAbstractClass(); 41 | 42 | 43 | $mockConfig = $this 44 | ->getMockBuilder(\Magento\Framework\View\Page\Config::class) 45 | ->disableOriginalConstructor() 46 | ->setMethods(['getTitle']) 47 | ->getMockForAbstractClass(); 48 | 49 | 50 | $mockPageResult->expects($this->any()) 51 | ->method('create') 52 | ->willReturn($mockPage); 53 | 54 | $mockPage->expects($this->any()) 55 | ->method('getConfig') 56 | ->willReturn($mockConfig); 57 | 58 | $mockConfig->expects($this->any()) 59 | ->method('getTitle') 60 | ->willReturn($this->titleMock); 61 | 62 | return $mockPageResult; 63 | } 64 | 65 | protected function getMockTitle() 66 | { 67 | $mockTitle = $this 68 | ->getMockBuilder(\Magento\Framework\View\Page\Title::class) 69 | ->disableOriginalConstructor() 70 | ->setMethods(['prepend']) 71 | ->getMockForAbstractClass(); 72 | 73 | return $mockTitle; 74 | } 75 | 76 | protected function getModel() 77 | { 78 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 79 | 80 | $model = $objectManager->getObject( 81 | \DEG\CustomReports\Controller\Adminhtml\CustomReport\NewAction::class, 82 | [ 83 | "context" => $this->contextMock, 84 | "resultPageFactory" => $this->resultPageFactory, 85 | ] 86 | ); 87 | 88 | return $model; 89 | } 90 | 91 | public function testExecuteExeptionType(): void 92 | { 93 | $this->titleMock->expects($this->at(0)) 94 | ->method('prepend') 95 | ->willReturn(__('New Report')); 96 | 97 | $this->getModel()->execute(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/ReportTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 47 | $this->requestMock = $this->createMock(RequestInterface::class); 48 | $this->context->method('getRequest')->willReturn($this->requestMock); 49 | 50 | $this->resultPageFactory = $this->createMock(PageFactory::class); 51 | $this->builder = $this->createMock(Builder::class); 52 | $this->report = new Report($this->context, $this->resultPageFactory, $this->builder); 53 | } 54 | 55 | /** 56 | * {@inheritdoc} 57 | */ 58 | protected function tearDown(): void 59 | { 60 | parent::tearDown(); 61 | 62 | unset($this->report); 63 | unset($this->context); 64 | unset($this->resultPageFactory); 65 | unset($this->builder); 66 | } 67 | 68 | public function testExecute(): void 69 | { 70 | $pageMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class) 71 | ->setMethods(['setActiveMenu', 'getConfig']) 72 | ->disableOriginalConstructor() 73 | ->getMock(); 74 | $this->resultPageFactory->method('create')->willReturn($pageMock); 75 | 76 | $configMock = $this->createMock(\Magento\Framework\View\Page\Config::class); 77 | $pageMock->method('getConfig')->willReturn($configMock); 78 | 79 | $titleMock = $this->createMock(\Magento\Framework\View\Page\Title::class); 80 | $configMock->method('getTitle')->willReturn($titleMock); 81 | 82 | $this->report->execute(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Test/Unit/Controller/Adminhtml/CustomReport/SaveTest.php: -------------------------------------------------------------------------------- 1 | context = $this->createMock(Context::class); 62 | $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); 63 | $this->context->method('getRequest')->willReturn($this->requestMock); 64 | 65 | $this->redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\RedirectFactory::class); 66 | $this->context->method('getResultRedirectFactory')->willReturn($this->redirectPageMock); 67 | 68 | $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); 69 | $this->context->method('getObjectManager')->willReturn($this->objectManagerMock); 70 | 71 | $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); 72 | $this->context->method('getMessageManager')->willReturn($this->messageManagerMock); 73 | 74 | $this->dataPersistor = $this->createMock(DataPersistorInterface::class); 75 | $this->automatedExportRepository = $this->createMock(CustomReportRepositoryInterface::class); 76 | $this->save = new Save($this->context, $this->dataPersistor, $this->automatedExportRepository); 77 | } 78 | 79 | /** 80 | * {@inheritdoc} 81 | */ 82 | protected function tearDown(): void 83 | { 84 | parent::tearDown(); 85 | 86 | unset($this->save); 87 | unset($this->context); 88 | unset($this->dataPersistor); 89 | unset($this->automatedExportRepository); 90 | } 91 | 92 | public function testExecute(): void 93 | { 94 | $data = [ 95 | 'customreport_id' => 1 96 | ]; 97 | $this->requestMock->method('getPostValue')->willReturn($data); 98 | 99 | $redirectPageMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); 100 | $this->redirectPageMock->method('create')->willReturn($redirectPageMock); 101 | 102 | $customReportMock = $this->createMock(\DEG\CustomReports\Model\CustomReport::class); 103 | $this->objectManagerMock->method('create')->willReturn($customReportMock); 104 | 105 | $redirectPageMock->method('setPath')->willReturnSelf(); 106 | 107 | $this->save->execute(); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Test/Unit/Model/AutomatedExport/DataProviderTest.php: -------------------------------------------------------------------------------- 1 | name = '42'; 65 | $this->primaryFieldName = '42'; 66 | $this->requestFieldName = '42'; 67 | 68 | $this->collectionFactory = $this->createMock(CollectionFactory::class); 69 | $this->collectionMock = $this->createMock 70 | (\DEG\CustomReports\Model\ResourceModel\AutomatedExport\Collection::class); 71 | $this->collectionFactory->method('create')->willReturn($this->collectionMock); 72 | 73 | $this->dataPersistor = $this->createMock(DataPersistorInterface::class); 74 | $this->meta = []; 75 | $this->data = []; 76 | $this->dataProvider = new DataProvider($this->name, $this->primaryFieldName, $this->requestFieldName, $this->collectionFactory, $this->dataPersistor, $this->meta, $this->data); 77 | } 78 | 79 | /** 80 | * {@inheritdoc} 81 | */ 82 | protected function tearDown(): void 83 | { 84 | parent::tearDown(); 85 | 86 | unset($this->dataProvider); 87 | unset($this->name); 88 | unset($this->primaryFieldName); 89 | unset($this->requestFieldName); 90 | unset($this->collectionFactory); 91 | unset($this->dataPersistor); 92 | unset($this->meta); 93 | unset($this->data); 94 | } 95 | 96 | public function testPrepareMeta(): void 97 | { 98 | $this->dataProvider->prepareMeta([]); 99 | } 100 | 101 | public function testGetData(): void 102 | { 103 | $this->collectionMock->method('addCustomreportIds')->willReturnSelf(); 104 | 105 | $dataObjectMock = $this->createMock(\Magento\Framework\DataObject::class); 106 | $this->collectionMock->method('getItems')->willReturn([$dataObjectMock]); 107 | 108 | $this->dataPersistor->method('get')->willReturn(1); 109 | $this->collectionMock->method('getNewEmptyItem')->willReturn($dataObjectMock); 110 | 111 | $this->dataProvider->getData(); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Test/Unit/Model/AutomatedExportLinkRepositoryTest.php: -------------------------------------------------------------------------------- 1 | automatedExportLinkFactory = $this->createMock(AutomatedExportLinkFactory::class); 48 | $this->collectionFactory = $this->createMock(CollectionFactory::class); 49 | $this->searchResultsFactory = $this->createMock(SearchResultsInterfaceFactory::class); 50 | $this->automatedExportLinkResource = $this->createMock(AutomatedExportLink::class); 51 | $this->automatedExportLinkRepository = new AutomatedExportLinkRepository($this->automatedExportLinkFactory, $this->collectionFactory, $this->searchResultsFactory, $this->automatedExportLinkResource); 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | protected function tearDown(): void 58 | { 59 | parent::tearDown(); 60 | 61 | unset($this->automatedExportLinkRepository); 62 | unset($this->automatedExportLinkFactory); 63 | unset($this->collectionFactory); 64 | unset($this->searchResultsFactory); 65 | unset($this->automatedExportLinkResource); 66 | } 67 | 68 | public function testSave(): void 69 | { 70 | $model = $this->createMock(\DEG\CustomReports\Model\AutomatedExportLink::class); 71 | 72 | $this->automatedExportLinkRepository->save($model); 73 | } 74 | 75 | public function testDeleteById(): void 76 | { 77 | $model = $this->createMock(\DEG\CustomReports\Model\AutomatedExportLink::class); 78 | $this->automatedExportLinkFactory->method('create')->willReturn($model); 79 | $model->method('getId')->willReturn(1); 80 | 81 | $this->automatedExportLinkRepository->deleteById(1); 82 | } 83 | 84 | public function testGetList(): void 85 | { 86 | $criteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); 87 | 88 | $searchMock = $this->createMock(\Magento\Framework\Api\SearchResultsInterface::class); 89 | $this->searchResultsFactory->method('create')->willReturn($searchMock); 90 | 91 | $filterGroup = $this->createMock(\Magento\Framework\Api\Search\FilterGroup::class); 92 | $criteriaMock->method('getFilterGroups')->willReturn([$filterGroup]); 93 | 94 | $filter = $this->createMock(\Magento\Framework\Api\Filter::class); 95 | $filterGroup->method('getFilters')->willReturn([$filter]); 96 | 97 | $collectionMock = $this->createMock(\DEG\CustomReports\Model\ResourceModel\AutomatedExportLink\Collection 98 | ::class); 99 | $this->collectionFactory->method('create')->willReturn($collectionMock); 100 | 101 | $sortOrdersMock = $this->createMock(\Magento\Framework\Api\SortOrder::class); 102 | $criteriaMock->method('getSortOrders')->willReturn([$sortOrdersMock]); 103 | 104 | $collectionMock->method('getIterator') 105 | ->willReturn(new \ArrayObject([$this->createMock(DataObject::class)])); 106 | 107 | $this->automatedExportLinkRepository->getList($criteriaMock); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Test/Unit/Model/AutomatedExportRepositoryTest.php: -------------------------------------------------------------------------------- 1 | automatedExportFactory = $this->createMock(AutomatedExportFactory::class); 48 | $this->collectionFactory = $this->createMock(CollectionFactory::class); 49 | $this->searchResultsFactory = $this->createMock(SearchResultsInterfaceFactory::class); 50 | $this->automatedExportResource = $this->createMock(AutomatedExport::class); 51 | $this->automatedExportRepository = new AutomatedExportRepository($this->automatedExportFactory, $this->collectionFactory, $this->searchResultsFactory, $this->automatedExportResource); 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | protected function tearDown(): void 58 | { 59 | parent::tearDown(); 60 | 61 | unset($this->automatedExportRepository); 62 | unset($this->automatedExportFactory); 63 | unset($this->collectionFactory); 64 | unset($this->searchResultsFactory); 65 | unset($this->automatedExportResource); 66 | } 67 | 68 | public function testSave(): void 69 | { 70 | $model = $this->createMock(\DEG\CustomReports\Model\AutomatedExport::class); 71 | 72 | $this->automatedExportRepository->save($model); 73 | } 74 | 75 | public function testDeleteById(): void 76 | { 77 | $model = $this->createMock(\DEG\CustomReports\Model\AutomatedExport::class); 78 | $this->automatedExportFactory->method('create')->willReturn($model); 79 | $model->method('getId')->willReturn(1); 80 | 81 | $this->automatedExportRepository->deleteById(1); 82 | } 83 | 84 | 85 | public function testGetList(): void 86 | { 87 | $criteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); 88 | 89 | $searchMock = $this->createMock(\Magento\Framework\Api\SearchResultsInterface::class); 90 | $this->searchResultsFactory->method('create')->willReturn($searchMock); 91 | 92 | $filterGroup = $this->createMock(\Magento\Framework\Api\Search\FilterGroup::class); 93 | $criteriaMock->method('getFilterGroups')->willReturn([$filterGroup]); 94 | 95 | $filter = $this->createMock(\Magento\Framework\Api\Filter::class); 96 | $filterGroup->method('getFilters')->willReturn([$filter]); 97 | 98 | $collectionMock = $this->createMock(\DEG\CustomReports\Model\ResourceModel\AutomatedExport\Collection 99 | ::class); 100 | $this->collectionFactory->method('create')->willReturn($collectionMock); 101 | 102 | $sortOrdersMock = $this->createMock(\Magento\Framework\Api\SortOrder::class); 103 | $criteriaMock->method('getSortOrders')->willReturn([$sortOrdersMock]); 104 | 105 | $collectionMock->method('getIterator') 106 | ->willReturn(new \ArrayObject([$this->createMock(DataObject::class)])); 107 | 108 | $this->automatedExportRepository->getList($criteriaMock); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Test/Unit/Model/Config/Source/AutomatedExportsTest.php: -------------------------------------------------------------------------------- 1 | searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class); 35 | $this->automatedExportRepository = $this->createMock(AutomatedExportRepositoryInterface::class); 36 | $this->automatedExports = new AutomatedExports($this->searchCriteriaBuilder, $this->automatedExportRepository); 37 | } 38 | 39 | /** 40 | * {@inheritdoc} 41 | */ 42 | protected function tearDown(): void 43 | { 44 | parent::tearDown(); 45 | 46 | unset($this->automatedExports); 47 | unset($this->searchCriteriaBuilder); 48 | unset($this->automatedExportRepository); 49 | } 50 | 51 | public function testToOptionArray(): void 52 | { 53 | $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class); 54 | $this->searchCriteriaBuilder->method('create')->willReturn($searchCriteriaMock); 55 | 56 | $searchResults = $this->createMock(\Magento\Framework\Api\SearchResultsInterface::class); 57 | $this->automatedExportRepository->method('getList')->willReturn($searchResults); 58 | 59 | $this->automatedExports->toOptionArray(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Test/Unit/Model/Config/Source/CustomReportsTest.php: -------------------------------------------------------------------------------- 1 | customReportRepository = $this->createMock(CustomReportRepositoryInterface::class); 35 | $this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class); 36 | $this->customReports = new CustomReports($this->customReportRepository, $this->searchCriteriaBuilder); 37 | } 38 | 39 | /** 40 | * {@inheritdoc} 41 | */ 42 | protected function tearDown(): void 43 | { 44 | parent::tearDown(); 45 | 46 | unset($this->customReports); 47 | unset($this->customReportRepository); 48 | unset($this->searchCriteriaBuilder); 49 | } 50 | 51 | public function testToOptionArray(): void 52 | { 53 | $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class); 54 | $this->searchCriteriaBuilder->method('create')->willReturn($searchCriteriaMock); 55 | 56 | $searchResults = $this->createMock(\Magento\Framework\Api\SearchResultsInterface::class); 57 | $this->customReportRepository->method('getList')->willReturn($searchResults); 58 | 59 | $customReport = $this->createMock(\DEG\CustomReports\Model\CustomReport::class); 60 | $searchResults->method('getItems')->willReturn($customReport); 61 | 62 | $this->customReports->toOptionArray(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Test/Unit/Model/CustomReport/DataProviderTest.php: -------------------------------------------------------------------------------- 1 | name = '42'; 60 | $this->primaryFieldName = '42'; 61 | $this->requestFieldName = '42'; 62 | $this->collectionFactory = $this->createMock(CollectionFactory::class); 63 | $this->collectionMock = $this->createMock 64 | (\DEG\CustomReports\Model\ResourceModel\CustomReport\Collection::class); 65 | $this->collectionFactory->method('create')->willReturn($this->collectionMock); 66 | $this->dataPersistor = $this->createMock(DataPersistorInterface::class); 67 | $this->meta = []; 68 | $this->data = []; 69 | $this->dataProvider = new DataProvider($this->name, $this->primaryFieldName, $this->requestFieldName, $this->collectionFactory, $this->dataPersistor, $this->meta, $this->data); 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | protected function tearDown(): void 76 | { 77 | parent::tearDown(); 78 | 79 | unset($this->dataProvider); 80 | unset($this->name); 81 | unset($this->primaryFieldName); 82 | unset($this->requestFieldName); 83 | unset($this->collectionFactory); 84 | unset($this->dataPersistor); 85 | unset($this->meta); 86 | unset($this->data); 87 | } 88 | 89 | public function testPrepareMeta(): void 90 | { 91 | $this->dataProvider->prepareMeta([]); 92 | } 93 | 94 | public function testGetData(): void 95 | { 96 | $dataObjectMock = $this->createMock(\Magento\Framework\DataObject::class); 97 | $this->collectionMock->method('getItems')->willReturn([$dataObjectMock]); 98 | 99 | $this->dataPersistor->method('get')->willReturn(1); 100 | $this->collectionMock->method('getNewEmptyItem')->willReturn($dataObjectMock); 101 | 102 | $this->dataProvider->getData(); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Test/Unit/Model/CustomReportRepositoryTest.php: -------------------------------------------------------------------------------- 1 | customReportFactory = $this->createMock(CustomReportFactory::class); 48 | $this->collectionFactory = $this->createMock(CollectionFactory::class); 49 | $this->searchResultsFactory = $this->createMock(SearchResultsInterfaceFactory::class); 50 | $this->customReportResource = $this->createMock(CustomReport::class); 51 | $this->customReportRepository = new CustomReportRepository($this->customReportFactory, $this->collectionFactory, $this->searchResultsFactory, $this->customReportResource); 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | protected function tearDown(): void 58 | { 59 | parent::tearDown(); 60 | 61 | unset($this->customReportRepository); 62 | unset($this->customReportFactory); 63 | unset($this->collectionFactory); 64 | unset($this->searchResultsFactory); 65 | unset($this->customReportResource); 66 | } 67 | 68 | public function testSave(): void 69 | { 70 | $model = $this->createMock(\DEG\CustomReports\Model\CustomReport::class); 71 | 72 | $this->customReportRepository->save($model); 73 | } 74 | 75 | public function testDeleteById(): void 76 | { 77 | $model = $this->createMock(\DEG\CustomReports\Model\CustomReport::class); 78 | $this->customReportFactory->method('create')->willReturn($model); 79 | $model->method('getId')->willReturn(1); 80 | 81 | $this->customReportRepository->deleteById(1); 82 | } 83 | 84 | 85 | public function testGetList(): void 86 | { 87 | $criteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); 88 | 89 | $searchMock = $this->createMock(\Magento\Framework\Api\SearchResultsInterface::class); 90 | $this->searchResultsFactory->method('create')->willReturn($searchMock); 91 | 92 | $filterGroup = $this->createMock(\Magento\Framework\Api\Search\FilterGroup::class); 93 | $criteriaMock->method('getFilterGroups')->willReturn([$filterGroup]); 94 | 95 | $filter = $this->createMock(\Magento\Framework\Api\Filter::class); 96 | $filterGroup->method('getFilters')->willReturn([$filter]); 97 | 98 | $collectionMock = $this->createMock(\DEG\CustomReports\Model\ResourceModel\CustomReport\Collection 99 | ::class); 100 | $this->collectionFactory->method('create')->willReturn($collectionMock); 101 | 102 | $sortOrdersMock = $this->createMock(\Magento\Framework\Api\SortOrder::class); 103 | $criteriaMock->method('getSortOrders')->willReturn([$sortOrdersMock]); 104 | 105 | $collectionMock->method('getIterator') 106 | ->willReturn(new \ArrayObject([$this->createMock(DataObject::class)])); 107 | 108 | $this->customReportRepository->getList($criteriaMock); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Test/Unit/Model/Service/CreateDynamicCronTest.php: -------------------------------------------------------------------------------- 1 | configValueFactory = $this->createMock(ValueFactory::class); 29 | $this->createDynamicCron = new CreateDynamicCron($this->configValueFactory); 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | protected function tearDown(): void 36 | { 37 | parent::tearDown(); 38 | 39 | unset($this->createDynamicCron); 40 | unset($this->configValueFactory); 41 | } 42 | 43 | public function testExecute(): void 44 | { 45 | $automatedExport = $this->createMock(\DEG\CustomReports\Model\AutomatedExport::class); 46 | 47 | $valueMock = $this->getMockBuilder(\Magento\Framework\App\Config\Value::class) 48 | ->setMethods(['load', 'setValue', 'setPath', 'save']) 49 | ->disableOriginalConstructor() 50 | ->getMock(); 51 | $this->configValueFactory->method('create')->willReturn($valueMock); 52 | 53 | $valueMock->method('load')->willReturnSelf(); 54 | $valueMock->method('setValue')->willReturnSelf(); 55 | $valueMock->method('setPath')->willReturnSelf(); 56 | $valueMock->method('save')->willReturnSelf(); 57 | 58 | 59 | $this->createDynamicCron->execute($automatedExport); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Test/Unit/Model/Service/DeleteDynamicCronTest.php: -------------------------------------------------------------------------------- 1 | configValueFactory = $this->createMock(ValueFactory::class); 29 | $this->deleteDynamicCron = new DeleteDynamicCron($this->configValueFactory); 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | protected function tearDown(): void 36 | { 37 | parent::tearDown(); 38 | 39 | unset($this->deleteDynamicCron); 40 | unset($this->configValueFactory); 41 | } 42 | 43 | public function testExecute(): void 44 | { 45 | $automatedExportModelName = 'pathModel'; 46 | 47 | $valueMock = $this->getMockBuilder(\Magento\Framework\App\Config\Value::class) 48 | ->setMethods(['load', 'setValue', 'setPath', 'save', 'delete']) 49 | ->disableOriginalConstructor() 50 | ->getMock(); 51 | $this->configValueFactory->method('create')->willReturn($valueMock); 52 | 53 | $valueMock->method('load')->willReturnSelf(); 54 | $valueMock->method('delete')->willReturnSelf(); 55 | 56 | $this->deleteDynamicCron->execute($automatedExportModelName); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Ui/Component/Listing/Column/AutomatedExport/PageActions.php: -------------------------------------------------------------------------------- 1 | authorization = $authorization; 40 | } 41 | 42 | /** 43 | * @param array $dataSource 44 | * 45 | * @return array 46 | */ 47 | public function prepareDataSource(array $dataSource): array 48 | { 49 | if (isset($dataSource["data"]["items"])) { 50 | foreach ($dataSource["data"]["items"] as &$item) { 51 | $name = $this->getData("name"); 52 | $id = $item["automatedexport_id"] ?? "X"; 53 | if ($this->authorization->isAllowed('DEG_CustomReports::automatedexport_edit')) { 54 | $item[$name]["view"] = [ 55 | "href" => $this->getContext()->getUrl( 56 | "deg_customreports/automatedexport/edit", 57 | ["automatedexport_id" => $id] 58 | ), 59 | "label" => __("Edit"), 60 | ]; 61 | } 62 | } 63 | } 64 | 65 | return $dataSource; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Ui/Component/Listing/Column/CustomReport/PageActions.php: -------------------------------------------------------------------------------- 1 | authorization = $authorization; 40 | } 41 | 42 | /** 43 | * @param array $dataSource 44 | * 45 | * @return array 46 | */ 47 | public function prepareDataSource(array $dataSource): array 48 | { 49 | if (isset($dataSource["data"]["items"])) { 50 | foreach ($dataSource["data"]["items"] as &$item) { 51 | $name = $this->getData("name"); 52 | $id = $item["customreport_id"] ?? "X"; 53 | if ($this->authorization->isAllowed('DEG_CustomReports::customreport_edit')) { 54 | $item[$name]["view"] = [ 55 | "href" => $this->getContext()->getUrl( 56 | "deg_customreports/customreport/edit", 57 | ["customreport_id" => $id] 58 | ), 59 | "label" => __("Edit"), 60 | ]; 61 | } 62 | if ($this->authorization->isAllowed('DEG_CustomReports::customreport_view_report')) { 63 | $item[$name]["report"] = [ 64 | "href" => $this->getContext()->getUrl( 65 | "deg_customreports/customreport/report", 66 | ["customreport_id" => $id] 67 | ), 68 | "label" => __("Report"), 69 | ]; 70 | } 71 | } 72 | } 73 | 74 | return $dataSource; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Ui/Component/Listing/DataProviders/AutomatedExport/Listing.php: -------------------------------------------------------------------------------- 1 | collection = $collectionFactory->create(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Ui/Component/Listing/DataProviders/CustomReport/Listing.php: -------------------------------------------------------------------------------- 1 | collection = $collectionFactory->create(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "degdigital/magento2-customreports", 3 | "description": "A Magento 2 module that allows an administrator to create reports in the admin panel. This is modeled after the Clean Reports module for Magento 1.", 4 | "type": "magento2-module", 5 | "license": [ 6 | "OSL-3.0", 7 | "AFL-3.0" 8 | ], 9 | "autoload": { 10 | "files": [ "registration.php" ], 11 | "psr-4": { 12 | "DEG\\CustomReports\\": "" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /etc/adminhtml/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /etc/db_schema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
43 |
44 | -------------------------------------------------------------------------------- /etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Magento\Cron\Model\VirtualLogger 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_automatedexport_listing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_automatedexport_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_automatedexport_save.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_customreport_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_customreport_listing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_customreport_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_customreport_report.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /view/adminhtml/layout/deg_customreports_customreport_save.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | --------------------------------------------------------------------------------