@@ -69,18 +69,14 @@ protected function setUp()
69
69
->disableOriginalConstructor ()
70
70
->getMock ();
71
71
72
- $ this ->dataProviderMock = $ this ->getMockForAbstractClass (DataProviderInterface::class);
73
-
74
72
$ this ->contextMock ->expects ($ this ->any ())
75
73
->method ('getNamespace ' )
76
74
->willReturn (DateRange::NAME );
77
75
$ this ->contextMock ->expects ($ this ->any ())
78
76
->method ('addComponentDefinition ' )
79
77
->with (DateRange::NAME , ['extends ' => DateRange::NAME ]);
80
78
81
- $ this ->contextMock ->expects ($ this ->any ())
82
- ->method ('getDataProvider ' )
83
- ->willReturn ($ this ->dataProviderMock );
79
+ $ this ->dataProviderMock = $ this ->getMockForAbstractClass (DataProviderInterface::class);
84
80
}
85
81
86
82
/**
@@ -95,16 +91,21 @@ protected function setUp()
95
91
*/
96
92
public function testPrepare ($ name , $ filterData , $ expectedCondition )
97
93
{
98
- $ this ->contextMock ->expects ($ this ->any ())
99
- ->method ('getFiltersParams ' )
100
- ->willReturn ($ filterData );
101
-
94
+ /** @var FormDate PHPUnit_Framework_MockObject_MockObject|$uiComponent */
102
95
$ uiComponent = $ this ->getMockBuilder (FormDate::class)->disableOriginalConstructor ()->getMock ();
103
96
104
97
$ uiComponent ->expects ($ this ->any ())
105
98
->method ('getContext ' )
106
99
->willReturn ($ this ->contextMock );
107
100
101
+ $ this ->contextMock ->expects ($ this ->any ())
102
+ ->method ('getFiltersParams ' )
103
+ ->willReturn ($ filterData );
104
+
105
+ $ this ->contextMock ->expects ($ this ->any ())
106
+ ->method ('getDataProvider ' )
107
+ ->willReturn ($ this ->dataProviderMock );
108
+
108
109
if ($ expectedCondition !== null ) {
109
110
if (is_string ($ filterData [$ name ])) {
110
111
$ uiComponent ->expects (static ::once ())
@@ -115,11 +116,11 @@ public function testPrepare($name, $filterData, $expectedCondition)
115
116
$ uiComponent ->method ('convertDate ' )
116
117
->willReturnMap ([
117
118
[
118
- $ filterData [$ name ]['from ' ],
119
+ $ filterData [$ name ]['from ' ], 0 , 0 , 0 , true ,
119
120
new \DateTime ($ filterData [$ name ]['from ' ], new \DateTimeZone ('UTC ' ))
120
121
],
121
122
[
122
- $ filterData [$ name ]['to ' ],
123
+ $ filterData [$ name ]['to ' ], 23 , 59 , 59 , true ,
123
124
new \DateTime ($ filterData [$ name ]['to ' ] . ' 23:59:00 ' , new \DateTimeZone ('UTC ' ))
124
125
],
125
126
]);
@@ -158,23 +159,6 @@ public function testPrepare($name, $filterData, $expectedCondition)
158
159
->with ($ filterMock );
159
160
break ;
160
161
}
161
- } else {
162
- $ uiComponent ->method ('convertDate ' )
163
- ->willReturnMap ([
164
- [
165
- $ filterData [$ name ]['from ' ],
166
- new \DateTime ($ filterData [$ name ]['from ' ], new \DateTimeZone ('UTC ' ))
167
- ],
168
- [
169
- $ filterData [$ name ]['to ' ],
170
- new \DateTime ($ filterData [$ name ]['to ' ] . ' 23:59:00 ' , new \DateTimeZone ('UTC ' ))
171
- ],
172
- ]);
173
-
174
- $ filterMock = $ this ->getFilterMockWithoutExpectedCondition ();
175
- $ this ->dataProviderMock ->expects (static ::exactly (2 ))
176
- ->method ('addFilter ' )
177
- ->with ($ filterMock );
178
162
}
179
163
180
164
$ this ->uiComponentFactory ->expects ($ this ->any ())
@@ -226,31 +210,6 @@ private function getFilterMock($name, $expectedType, $expectedDate, &$i)
226
210
return $ filterMock ;
227
211
}
228
212
229
- /**
230
- * Gets Filter mock without expected condition
231
- *
232
- * @return Filter|\PHPUnit_Framework_MockObject_MockObject
233
- */
234
- private function getFilterMockWithoutExpectedCondition ()
235
- {
236
- $ this ->filterBuilderMock ->expects (static ::exactly (2 ))
237
- ->method ('setConditionType ' )
238
- ->willReturnSelf ();
239
- $ this ->filterBuilderMock ->expects (static ::exactly (2 ))
240
- ->method ('setField ' )
241
- ->willReturnSelf ();
242
- $ this ->filterBuilderMock ->expects (static ::exactly (2 ))
243
- ->method ('setValue ' )
244
- ->willReturnSelf ();
245
-
246
- $ filterMock = $ this ->getMock (Filter::class);
247
- $ this ->filterBuilderMock ->expects (static ::exactly (2 ))
248
- ->method ('create ' )
249
- ->willReturn ($ filterMock );
250
-
251
- return $ filterMock ;
252
- }
253
-
254
213
/**
255
214
* @return array
256
215
*/
0 commit comments