|
6 | 6 |
|
7 | 7 | namespace Magento\Reports\Test\Unit\Model\ResourceModel\Report;
|
8 | 8 |
|
| 9 | +use Magento\Framework\Data\Collection\EntityFactory; |
| 10 | +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; |
9 | 11 | use Magento\Reports\Model\ResourceModel\Report\Collection;
|
| 12 | +use Magento\Reports\Model\ResourceModel\Report\Collection\Factory as ReportCollectionFactory; |
10 | 13 |
|
| 14 | +/** |
| 15 | + * Class CollectionTest |
| 16 | + * |
| 17 | + * @covers \Magento\Reports\Model\ResourceModel\Report\Collection |
| 18 | + */ |
11 | 19 | class CollectionTest extends \PHPUnit\Framework\TestCase
|
12 | 20 | {
|
13 | 21 | /**
|
14 |
| - * @var \Magento\Reports\Model\ResourceModel\Report\Collection |
| 22 | + * @var Collection |
15 | 23 | */
|
16 | 24 | protected $collection;
|
17 | 25 |
|
18 | 26 | /**
|
19 |
| - * @var \Magento\Framework\Data\Collection\EntityFactory|\PHPUnit_Framework_MockObject_MockObject |
| 27 | + * @var EntityFactory|\PHPUnit_Framework_MockObject_MockObject |
20 | 28 | */
|
21 | 29 | protected $entityFactoryMock;
|
22 | 30 |
|
23 | 31 | /**
|
24 |
| - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject |
| 32 | + * @var TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject |
25 | 33 | */
|
26 | 34 | protected $timezoneMock;
|
27 | 35 |
|
28 | 36 | /**
|
29 |
| - * @var \Magento\Reports\Model\ResourceModel\Report\Collection\Factory|\PHPUnit_Framework_MockObject_MockObject |
| 37 | + * @var ReportCollectionFactory|\PHPUnit_Framework_MockObject_MockObject |
30 | 38 | */
|
31 | 39 | protected $factoryMock;
|
32 | 40 |
|
33 | 41 | /**
|
34 |
| - * {@inheritDoc} |
| 42 | + * @inheritDoc |
35 | 43 | */
|
36 | 44 | protected function setUp()
|
37 | 45 | {
|
38 |
| - $this->entityFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\EntityFactory::class) |
39 |
| - ->disableOriginalConstructor() |
40 |
| - ->getMock(); |
41 |
| - $this->timezoneMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) |
42 |
| - ->getMock(); |
43 |
| - $this->factoryMock = $this->getMockBuilder( |
44 |
| - \Magento\Reports\Model\ResourceModel\Report\Collection\Factory::class |
45 |
| - )->disableOriginalConstructor() |
46 |
| - ->getMock(); |
47 |
| - |
48 |
| - $this->timezoneMock |
49 |
| - ->expects($this->any()) |
50 |
| - ->method('formatDateTime') |
51 |
| - ->will($this->returnCallback([$this, 'formatDateTime'])); |
| 46 | + $this->entityFactoryMock = $this->createMock(EntityFactory::class); |
| 47 | + $this->timezoneMock = $this->createMock(TimezoneInterface::class); |
| 48 | + $this->factoryMock = $this->createMock(ReportCollectionFactory::class); |
| 49 | + |
| 50 | + $this->timezoneMock->method('formatDate') |
| 51 | + ->will($this->returnCallback([$this, 'formatDate'])); |
52 | 52 |
|
53 | 53 | $this->collection = new Collection(
|
54 | 54 | $this->entityFactoryMock,
|
@@ -131,7 +131,7 @@ public function testGetReports($period, $fromDate, $toDate, $size)
|
131 | 131 | public function testLoadData()
|
132 | 132 | {
|
133 | 133 | $this->assertInstanceOf(
|
134 |
| - \Magento\Reports\Model\ResourceModel\Report\Collection::class, |
| 134 | + Collection::class, |
135 | 135 | $this->collection->loadData()
|
136 | 136 | );
|
137 | 137 | }
|
@@ -182,14 +182,11 @@ public function intervalsDataProvider()
|
182 | 182 | }
|
183 | 183 |
|
184 | 184 | /**
|
| 185 | + * @param \DateTimeInterface $dateStart |
185 | 186 | * @return string
|
186 | 187 | */
|
187 |
| - public function formatDateTime() |
| 188 | + public function formatDate(\DateTimeInterface $dateStart): string |
188 | 189 | {
|
189 |
| - $args = func_get_args(); |
190 |
| - |
191 |
| - $dateStart = $args[0]; |
192 |
| - |
193 | 190 | $formatter = new \IntlDateFormatter(
|
194 | 191 | "en_US",
|
195 | 192 | \IntlDateFormatter::SHORT,
|
|
0 commit comments