@@ -97,18 +97,12 @@ public function testGetComponentName(): void
97
97
* @param bool $showsTime
98
98
* @param array $filterData
99
99
* @param array|null $expectedCondition
100
- * @param string|null $dateFormat
101
100
*
102
101
* @return void
103
102
* @dataProvider getPrepareDataProvider
104
103
*/
105
- public function testPrepare (
106
- string $ name ,
107
- bool $ showsTime ,
108
- array $ filterData ,
109
- ?array $ expectedCondition ,
110
- ?string $ dateFormat
111
- ): void {
104
+ public function testPrepare (string $ name , bool $ showsTime , array $ filterData , ?array $ expectedCondition ): void
105
+ {
112
106
$ processor = $ this ->getMockBuilder (Processor::class)
113
107
->disableOriginalConstructor ()
114
108
->getMock ();
@@ -138,7 +132,7 @@ public function testPrepare(
138
132
->willReturn ($ this ->dataProviderMock );
139
133
140
134
if ($ expectedCondition !== null ) {
141
- $ this ->processFilters ($ name , $ showsTime , $ filterData , $ expectedCondition , $ dateFormat , $ uiComponent );
135
+ $ this ->processFilters ($ name , $ showsTime , $ filterData , $ expectedCondition , $ uiComponent );
142
136
}
143
137
144
138
$ this ->uiComponentFactory ->expects ($ this ->any ())
@@ -154,7 +148,7 @@ public function testPrepare(
154
148
[],
155
149
[
156
150
'name ' => $ name ,
157
- 'config ' => ['options ' => ['showsTime ' => $ showsTime ], ' dateFormat ' => $ dateFormat ],
151
+ 'config ' => ['options ' => ['showsTime ' => $ showsTime ]],
158
152
]
159
153
);
160
154
$ date ->prepare ();
@@ -170,15 +164,13 @@ public function getPrepareDataProvider(): array
170
164
'name ' => 'test_date ' ,
171
165
'showsTime ' => false ,
172
166
'filterData ' => ['test_date ' => ['from ' => '11-05-2015 ' , 'to ' => null ]],
173
- 'expectedCondition ' => ['date ' => '2015-05-11 00:00:00 ' , 'type ' => 'gteq ' ],
174
- 'dateFormat ' => null
167
+ 'expectedCondition ' => ['date ' => '2015-05-11 00:00:00 ' , 'type ' => 'gteq ' ]
175
168
],
176
169
[
177
170
'name ' => 'test_date ' ,
178
171
'showsTime ' => false ,
179
172
'filterData ' => ['test_date ' => ['from ' => null , 'to ' => '11-05-2015 ' ]],
180
- 'expectedCondition ' => ['date ' => '2015-05-11 23:59:59 ' , 'type ' => 'lteq ' ],
181
- 'dateFormat ' => null
173
+ 'expectedCondition ' => ['date ' => '2015-05-11 23:59:59 ' , 'type ' => 'lteq ' ]
182
174
],
183
175
[
184
176
'name ' => 'test_date ' ,
@@ -187,22 +179,19 @@ public function getPrepareDataProvider(): array
187
179
'expectedCondition ' => [
188
180
'date_from ' => '2015-05-11 00:00:00 ' , 'type_from ' => 'gteq ' ,
189
181
'date_to ' => '2015-05-11 23:59:59 ' , 'type_to ' => 'lteq '
190
- ],
191
- 'dateFormat ' => null
182
+ ]
192
183
],
193
184
[
194
185
'name ' => 'test_date ' ,
195
186
'showsTime ' => false ,
196
187
'filterData ' => ['test_date ' => '11-05-2015 ' ],
197
- 'expectedCondition ' => ['date ' => '2015-05-11 00:00:00 ' , 'type ' => 'eq ' ],
198
- 'dateFormat ' => null
188
+ 'expectedCondition ' => ['date ' => '2015-05-11 00:00:00 ' , 'type ' => 'eq ' ]
199
189
],
200
190
[
201
191
'name ' => 'test_date ' ,
202
192
'showsTime ' => false ,
203
193
'filterData ' => ['test_date ' => ['from ' => '' , 'to ' => '' ]],
204
- 'expectedCondition ' => null ,
205
- 'dateFormat ' => null
194
+ 'expectedCondition ' => null
206
195
],
207
196
[
208
197
'name ' => 'test_date ' ,
@@ -211,18 +200,7 @@ public function getPrepareDataProvider(): array
211
200
'expectedCondition ' => [
212
201
'date_from ' => '2015-05-11 10:20:00 ' , 'type_from ' => 'gteq ' ,
213
202
'date_to ' => '2015-05-11 18:25:00 ' , 'type_to ' => 'lteq '
214
- ],
215
- 'dateFormat ' => null
216
- ],
217
- [
218
- 'name ' => 'test_date ' ,
219
- 'showsTime ' => false ,
220
- 'filterData ' => ['test_date ' => ['from ' => '2015-05-11 ' , 'to ' => '2015-05-11 ' ]],
221
- 'expectedCondition ' => [
222
- 'date_from ' => '2015-05-11 00:00:00 ' , 'type_from ' => 'gteq ' ,
223
- 'date_to ' => '2015-05-11 23:59:59 ' , 'type_to ' => 'lteq '
224
- ],
225
- 'dateFormat ' => 'Y-MM-dd '
203
+ ]
226
204
]
227
205
];
228
206
}
@@ -232,19 +210,16 @@ public function getPrepareDataProvider(): array
232
210
* @param bool $showsTime
233
211
* @param array $filterData
234
212
* @param array $expectedCondition
235
- * @param string|null $dateFormat
236
213
* @param MockObject $uiComponent
237
214
*
238
215
* @return void
239
216
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
240
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
241
217
*/
242
218
private function processFilters (
243
219
string $ name ,
244
220
bool $ showsTime ,
245
221
array $ filterData ,
246
222
array $ expectedCondition ,
247
- string |null $ dateFormat ,
248
223
FormDate $ uiComponent
249
224
): void {
250
225
if (is_string ($ filterData [$ name ])) {
@@ -264,18 +239,6 @@ private function processFilters(
264
239
]
265
240
);
266
241
} else {
267
- if ($ dateFormat === 'Y-MM-dd ' ) {
268
- $ uiComponent ->method ('convertDateFormat ' )
269
- ->willReturn (
270
- date_format (date_create ($ filterData [$ name ]['from ' ]), 'm/d/Y ' )
271
- );
272
- $ uiComponent ->method ('convertDateFormat ' )
273
- ->willReturn (
274
- date_format (date_create ($ filterData [$ name ]['to ' ]), 'm/d/Y ' )
275
- );
276
- $ filterData [$ name ]['from ' ] = date_format (date_create ($ filterData [$ name ]['from ' ]), 'm/d/Y ' );
277
- $ filterData [$ name ]['to ' ] = date_format (date_create ($ filterData [$ name ]['to ' ]), 'm/d/Y ' );
278
- }
279
242
$ from = new \DateTime ($ filterData [$ name ]['from ' ] ?? 'now ' );
280
243
$ to = new \DateTime ($ filterData [$ name ]['to ' ] ? $ filterData [$ name ]['to ' ] . ' 23:59:59 ' : 'now ' );
281
244
$ uiComponent ->method ('convertDate ' )
0 commit comments