11 class DataTest extends \PHPUnit\Framework\TestCase
33 $this->contextMock = $this->getMockBuilder(\
Magento\Framework\
App\Helper\Context::class)
34 ->disableOriginalConstructor()
36 $this->itemFactoryMock = $this->getMockBuilder(\
Magento\Reports\Model\ItemFactory::class)
37 ->setMethods([
'create'])
38 ->disableOriginalConstructor()
41 $this->data =
new Data(
43 $this->itemFactoryMock
57 $this->assertEquals($this->data->getIntervals($from, $to, $period),
$results);
71 ->disableOriginalConstructor()
72 ->setMethods([
'addItem'])
75 $item = $this->getMockBuilder(\
Magento\Reports\Model\Item::class)
76 ->disableOriginalConstructor()
77 ->setMethods([
'setPeriod',
'setIsEmpty'])
80 $this->itemFactoryMock->expects($this->exactly(count(
$results)))
84 ->method(
'setIsEmpty');
89 $item->expects($this->at($key + $key))
94 $this->data->prepareIntervalsCollection(
$collection, $from, $to, $period);
104 'from' =>
'2000-01-15 10:00:00',
105 'to' =>
'2000-01-15 11:00:00',
107 'results' => [
'2000-01-15']
110 'from' =>
'2000-01-15 10:00:00',
111 'to' =>
'2000-01-17 10:00:00',
113 'results' => [
'2000-01']
116 'from' =>
'2000-01-15 10:00:00',
117 'to' =>
'2000-02-15 10:00:00',
119 'results' => [
'2000']
122 'from' =>
'2000-01-15 10:00:00',
123 'to' =>
'2000-01-16 11:00:00',
125 'results' => [
'2000-01-15',
'2000-01-16']
128 'from' =>
'2000-01-15 10:00:00',
129 'to' =>
'2000-02-17 10:00:00',
131 'results' => [
'2000-01',
'2000-02']
134 'from' =>
'2000-01-15 10:00:00',
135 'to' =>
'2003-02-15 10:00:00',
137 'results' => [
'2000',
'2001',
'2002',
'2003']
const REPORT_PERIOD_TYPE_YEAR
testGetIntervals($from, $to, $period, $results)
const REPORT_PERIOD_TYPE_DAY
const REPORT_PERIOD_TYPE_MONTH
testPrepareIntervalsCollection($from, $to, $period, $results)