Skip to content

Commit d48cc2f

Browse files
committed
improvement: cover Chart with integration test
1 parent 5da031e commit d48cc2f

File tree

1 file changed

+81
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Backend/Model/Dashboard

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Model;
9+
10+
use Magento\Backend\Model\Dashboard\Chart;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use PHPUnit\Framework\TestCase;
13+
14+
/**
15+
* Verify chart data by different period.
16+
*
17+
* @magentoAppArea adminhtml
18+
*/
19+
class ChartTest extends TestCase
20+
{
21+
/**
22+
* @var Chart
23+
*/
24+
private $model;
25+
26+
/**
27+
* @inheritdoc
28+
*/
29+
protected function setUp()
30+
{
31+
$this->model = Bootstrap::getObjectManager()->create(Chart::class);
32+
}
33+
34+
/**
35+
* Verify getByPeriod with all types of period
36+
*
37+
* @magentoDataFixture Magento/Sales/_files/order_list_with_invoice.php
38+
* @dataProvider getChartDataProvider
39+
* @return void
40+
*/
41+
public function testGetByPeriodWithParam(int $expectedDataQty, string $period, string $chartParam): void
42+
{
43+
$this->assertCount($expectedDataQty, $this->model->getByPeriod($period, $chartParam));
44+
}
45+
46+
/**
47+
* Expected chart data
48+
*
49+
* @return array
50+
*/
51+
public function getChartDataProvider(): array
52+
{
53+
return [
54+
[
55+
24,
56+
'24h',
57+
'quantity'
58+
],
59+
[
60+
8,
61+
'7d',
62+
'quantity'
63+
],
64+
[
65+
6,
66+
'1m',
67+
'quantity'
68+
],
69+
[
70+
16,
71+
'1y',
72+
'quantity'
73+
],
74+
[
75+
28,
76+
'2y',
77+
'quantity'
78+
]
79+
];
80+
}
81+
}

0 commit comments

Comments
 (0)