|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\MagentoBundle\Tests\Functiona\Dashboard; |
|
4
|
|
|
|
|
5
|
|
|
use Oro\Bundle\ChartBundle\Model\ChartViewBuilder; |
|
6
|
|
|
use Oro\Bundle\ConfigBundle\Config\ConfigManager; |
|
7
|
|
|
use Oro\Bundle\FilterBundle\Form\Type\Filter\AbstractDateFilterType; |
|
8
|
|
|
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase; |
|
9
|
|
|
|
|
10
|
|
|
use OroCRM\Bundle\MagentoBundle\Tests\Functional\Fixture\LoadOrderDataWithFixedDate; |
|
11
|
|
|
use OroCRM\Bundle\MagentoBundle\Dashboard\OrderDataProvider as DataProvider; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @dbIsolation |
|
15
|
|
|
*/ |
|
16
|
|
|
class OrderDataProviderTest extends WebTestCase |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var DataProvider */ |
|
19
|
|
|
protected $orderDataProvider; |
|
20
|
|
|
|
|
21
|
|
|
/** @var ConfigManager */ |
|
22
|
|
|
protected $configManager; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
protected $savedTimezone; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
|
|
protected function setUp() |
|
31
|
|
|
{ |
|
32
|
|
|
parent::setUp(); |
|
33
|
|
|
$this->initClient(); |
|
34
|
|
|
|
|
35
|
|
|
$this->configManager = $this |
|
36
|
|
|
->getClientInstance() |
|
37
|
|
|
->getContainer() |
|
38
|
|
|
->get('oro_config.user'); |
|
39
|
|
|
|
|
40
|
|
|
$this->savedTimezone = $this->configManager->get('oro_locale.timezone'); |
|
41
|
|
|
$this->configManager->set('oro_locale.timezone', 'Europe/Berlin'); |
|
42
|
|
|
|
|
43
|
|
|
$this->orderDataProvider = $this |
|
44
|
|
|
->getClientInstance() |
|
45
|
|
|
->getContainer() |
|
46
|
|
|
->get('orocrm_magento.dashboard.data_provider.order'); |
|
47
|
|
|
|
|
48
|
|
|
$this->loadFixtures( |
|
49
|
|
|
[ |
|
50
|
|
|
LoadOrderDataWithFixedDate::class |
|
51
|
|
|
] |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritdoc} |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function tearDown() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->configManager->set('oro_locale.timezone', $this->savedTimezone); |
|
61
|
|
|
unset( |
|
62
|
|
|
$this->orderDataProvider, |
|
63
|
|
|
$this->configManager |
|
64
|
|
|
); |
|
65
|
|
|
parent::tearDown(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function testGetRevenueOverTimeChartViewWithNonUTCTimezoneOnSelectedDate() |
|
69
|
|
|
{ |
|
70
|
|
|
/** |
|
71
|
|
|
* @var $chartViewBuilder ChartViewBuilder | \PHPUnit_Framework_MockObject_MockObject |
|
72
|
|
|
*/ |
|
73
|
|
|
$chartViewBuilder = $this |
|
74
|
|
|
->getMockBuilder(ChartViewBuilder::class) |
|
75
|
|
|
->disableOriginalConstructor() |
|
76
|
|
|
->getMock(); |
|
77
|
|
|
|
|
78
|
|
|
$chartViewBuilder |
|
|
|
|
|
|
79
|
|
|
->expects($this->atLeastOnce()) |
|
80
|
|
|
->method('setOptions') |
|
81
|
|
|
->willReturnSelf(); |
|
82
|
|
|
|
|
83
|
|
|
$chartViewBuilder |
|
|
|
|
|
|
84
|
|
|
->expects($this->once()) |
|
85
|
|
|
->method('getView') |
|
86
|
|
|
->willReturn(true); |
|
87
|
|
|
|
|
88
|
|
|
$chartViewBuilder |
|
|
|
|
|
|
89
|
|
|
->expects($this->once()) |
|
90
|
|
|
->method('setArrayData') |
|
91
|
|
|
->with( |
|
92
|
|
|
$this->equalTo($this->getDataForTestGetRevenueOver()) |
|
93
|
|
|
) |
|
94
|
|
|
->willReturnSelf(); |
|
95
|
|
|
|
|
96
|
|
|
$timezoneFromConfig = new \DateTimeZone($this->configManager->get('oro_locale.timezone')); |
|
97
|
|
|
|
|
98
|
|
|
$this->orderDataProvider->getRevenueOverTimeChartView( |
|
99
|
|
|
$chartViewBuilder, |
|
100
|
|
|
[ |
|
101
|
|
|
'start' => new \DateTime('2017-07-01 00:00:00', $timezoneFromConfig), |
|
102
|
|
|
'end' => new \DateTime('2017-07-04 23:59:59', $timezoneFromConfig), |
|
103
|
|
|
'type' => AbstractDateFilterType::TYPE_BETWEEN, |
|
104
|
|
|
'part' => 'value' |
|
105
|
|
|
] |
|
106
|
|
|
); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return array |
|
111
|
|
|
*/ |
|
112
|
|
|
protected function getDataForTestGetRevenueOver() |
|
113
|
|
|
{ |
|
114
|
|
|
return [ |
|
115
|
|
|
'Jun 27, 2017 - Jul 1, 2017' => [ |
|
116
|
|
|
[ |
|
117
|
|
|
'date' => '2017-07-01', |
|
118
|
|
|
], |
|
119
|
|
|
[ |
|
120
|
|
|
'date' => '2017-07-02', |
|
121
|
|
|
], |
|
122
|
|
|
[ |
|
123
|
|
|
'date' => '2017-07-03', |
|
124
|
|
|
], |
|
125
|
|
|
[ |
|
126
|
|
|
'date' => '2017-07-04', |
|
127
|
|
|
'amount' => '13.4500' |
|
128
|
|
|
] |
|
129
|
|
|
], |
|
130
|
|
|
'Jul 1, 2017 - Jul 4, 2017' => [ |
|
131
|
|
|
[ |
|
132
|
|
|
'date' => '2017-07-01', |
|
133
|
|
|
'amount' => '11.1000' |
|
134
|
|
|
], |
|
135
|
|
|
[ |
|
136
|
|
|
'date' => '2017-07-02', |
|
137
|
|
|
], |
|
138
|
|
|
[ |
|
139
|
|
|
'date' => '2017-07-03', |
|
140
|
|
|
], |
|
141
|
|
|
[ |
|
142
|
|
|
'date' => '2017-07-04', |
|
143
|
|
|
'amount' => '11.1000' |
|
144
|
|
|
] |
|
145
|
|
|
], |
|
146
|
|
|
]; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.