/** * Refresh sales order report statistics for last day * * @return void */ public function execute() { $this->localeResolver->emulate(0); $currentDate = $this->localeDate->date(); $date = $currentDate->sub(new \DateInterval('PT25H')); $this->orderFactory->create()->aggregate($date); $this->localeResolver->revert(); }
public function testExecute() { $date = $this->setupAggregate(); $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\ResourceModel\\Report\\Order')->disableOriginalConstructor()->getMock(); $orderMock->expects($this->once())->method('aggregate')->with($date); $this->orderFactoryMock->expects($this->once())->method('create')->will($this->returnValue($orderMock)); $this->observer->execute(); }
/** * @param int $useAggregatedData * @param string $mainTable * @param int $isFilter * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getIfNullSqlResult * @dataProvider useAggregatedDataDataProvider * @return void */ public function testPrepareSummary($useAggregatedData, $mainTable, $isFilter, $getIfNullSqlResult) { $range = ''; $customStart = 1; $customEnd = 10; $this->scopeConfigMock ->expects($this->once()) ->method('getValue') ->with( 'sales/dashboard/use_aggregated_data', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) ->willReturn($useAggregatedData); $orderMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Report\Order') ->disableOriginalConstructor() ->getMock(); $this->orderFactoryMock ->expects($this->any()) ->method('create') ->willReturn($orderMock); $this->resourceMock ->expects($this->at(0)) ->method('getTable') ->with($mainTable); $this->connectionMock ->expects($getIfNullSqlResult) ->method('getIfNullSql'); $this->collection->prepareSummary($range, $customStart, $customEnd, $isFilter); }
/** * Retrieve query for attribute with timezone conversion * * @param string $range * @param string $attribute * @param string|null $from * @param string|null $to * @return string */ protected function _getTZRangeOffsetExpression($range, $attribute, $from = null, $to = null) { return str_replace('{{attribute}}', $this->_reportOrderFactory->create()->getStoreTZOffsetQuery($this->getMainTable(), $attribute, $from, $to), $this->_getRangeExpression($range)); }