@@ -49,15 +49,18 @@ protected function setUp()
49
49
* @magentoDataFixture Magento/Sales/_files/order_list_with_invoice.php
50
50
* @dataProvider chartUrlDataProvider
51
51
* @param string $period
52
- * @param string $expectedAxisRange
53
52
* @return void
54
53
*/
55
- public function testGetChartUrl (string $ period, string $ expectedAxisRange ): void
54
+ public function testGetChartUrl (string $ period ): void
56
55
{
57
56
$ this ->graphBlock ->getRequest ()->setParams (['period ' => $ period ]);
57
+ /** @var Orders $ordersBlock */
58
58
$ ordersBlock = $ this ->layout ->createBlock (Orders::class);
59
59
$ decodedChartUrl = urldecode ($ ordersBlock ->getChartUrl ());
60
- $ this ->assertEquals ($ expectedAxisRange , $ this ->getUrlParamData ($ decodedChartUrl , 'chxr ' ));
60
+ $ this ->assertEquals (
61
+ $ this ->getExpectedAxisRange ($ ordersBlock ),
62
+ $ this ->getUrlParamData ($ decodedChartUrl , 'chxr ' )
63
+ );
61
64
}
62
65
63
66
/**
@@ -66,11 +69,11 @@ public function testGetChartUrl(string $period, string $expectedAxisRange): void
66
69
public function chartUrlDataProvider (): array
67
70
{
68
71
return [
69
- 'Last 24 Hours ' => ['24h ' , ' 1,0,2,1 ' ],
70
- 'Last 7 Days ' => ['7d ' , ' 1,0,3,1 ' ],
71
- 'Current Month ' => ['1m ' , ' 1,0,3,1 ' ],
72
- 'YTD ' => ['1y ' , ' 1,0,4,1 ' ],
73
- '2YTD ' => ['2y ' , ' 1,0,4,1 ' ],
72
+ 'Last 24 Hours ' => ['24h ' ],
73
+ 'Last 7 Days ' => ['7d ' ],
74
+ 'Current Month ' => ['1m ' ],
75
+ 'YTD ' => ['1y ' ],
76
+ '2YTD ' => ['2y ' ],
74
77
];
75
78
}
76
79
@@ -91,4 +94,20 @@ private function getUrlParamData(string $chartUrl, string $paramName): string
91
94
92
95
return '' ;
93
96
}
97
+
98
+ /**
99
+ * @param Orders $ordersBlock
100
+ * @return string
101
+ */
102
+ private function getExpectedAxisRange (Orders $ ordersBlock ): string
103
+ {
104
+ $ dashboardOrders = $ ordersBlock ->getDataHelper ()->getItems ();
105
+ $ ordersQty = array_map (function ($ order ) {
106
+ return $ order ->getQuantity ();
107
+ }, $ dashboardOrders );
108
+
109
+ $ axisPeak = max (array_values ($ ordersQty )) + 1 ;
110
+
111
+ return "1,0, {$ axisPeak },1 " ;
112
+ }
94
113
}
0 commit comments