@@ -97,14 +97,15 @@ public function testGetComponentName()
97
97
/**
98
98
* Run test prepare method
99
99
*
100
- * @param string $name
100
+ * @param array $data
101
101
* @param array $filterData
102
102
* @param array|null $expectedCondition
103
103
* @dataProvider getPrepareDataProvider
104
104
* @return void
105
105
*/
106
- public function testPrepare ($ name , $ filterData , $ expectedCondition )
106
+ public function testPrepare ($ data , $ filterData , $ expectedCondition )
107
107
{
108
+ $ name = $ data ['name ' ];
108
109
/** @var UiComponentInterface $uiComponent */
109
110
$ uiComponent = $ this ->getMockForAbstractClass (
110
111
'Magento\Framework\View\Element\UiComponentInterface ' ,
@@ -124,13 +125,12 @@ public function testPrepare($name, $filterData, $expectedCondition)
124
125
->method ('addComponentDefinition ' )
125
126
->with (Select::NAME , ['extends ' => Select::NAME ]);
126
127
$ this ->contextMock ->expects ($ this ->any ())
127
- ->method ('getRequestParam ' )
128
- ->with (AbstractFilter::FILTER_VAR )
128
+ ->method ('getFiltersParams ' )
129
129
->willReturn ($ filterData );
130
130
/** @var DataProviderInterface $dataProvider */
131
131
$ dataProvider = $ this ->getMockForAbstractClass (
132
132
'Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface ' ,
133
- [],
133
+ [' addFilter ' ],
134
134
'' ,
135
135
false
136
136
);
@@ -139,9 +139,24 @@ public function testPrepare($name, $filterData, $expectedCondition)
139
139
->willReturn ($ dataProvider );
140
140
141
141
if ($ expectedCondition !== null ) {
142
+ $ filterMock = $ this ->getMock ('Magento\Framework\Api\Filter ' );
143
+ $ this ->filterBuilderMock ->expects ($ this ->any ())
144
+ ->method ('setConditionType ' )
145
+ ->with ($ expectedCondition )
146
+ ->willReturnSelf ();
147
+ $ this ->filterBuilderMock ->expects ($ this ->any ())
148
+ ->method ('setField ' )
149
+ ->with ($ name )
150
+ ->willReturnSelf ();
151
+ $ this ->filterBuilderMock ->expects ($ this ->any ())
152
+ ->method ('setValue ' )
153
+ ->willReturnSelf ();
154
+ $ this ->filterBuilderMock ->expects ($ this ->any ())
155
+ ->method ('create ' )
156
+ ->willReturn ($ filterMock );
142
157
$ dataProvider ->expects ($ this ->any ())
143
158
->method ('addFilter ' )
144
- ->with ($ expectedCondition , $ name );
159
+ ->with ($ filterMock );
145
160
}
146
161
147
162
/** @var \Magento\Framework\Data\OptionSourceInterface $selectOptions */
@@ -164,7 +179,7 @@ public function testPrepare($name, $filterData, $expectedCondition)
164
179
$ this ->filterModifierMock ,
165
180
$ selectOptions ,
166
181
[],
167
- [ ' name ' => $ name ]
182
+ $ data
168
183
);
169
184
170
185
$ date ->prepare ();
@@ -177,14 +192,29 @@ public function getPrepareDataProvider()
177
192
{
178
193
return [
179
194
[
180
- 'test_date ' ,
195
+ ['name ' => 'test_date ' , 'config ' => []],
196
+ [],
197
+ null
198
+ ],
199
+ [
200
+ ['name ' => 'test_date ' , 'config ' => []],
181
201
['test_date ' => '' ],
182
- null ,
202
+ 'eq '
203
+ ],
204
+ [
205
+ ['name ' => 'test_date ' , 'config ' => ['dataType ' => 'text ' ]],
206
+ ['test_date ' => 'some_value ' ],
207
+ 'eq '
208
+ ],
209
+ [
210
+ ['name ' => 'test_date ' , 'config ' => ['dataType ' => 'select ' ]],
211
+ ['test_date ' => ['some_value1 ' , 'some_value2 ' ]],
212
+ 'in '
183
213
],
184
214
[
185
- ' test_date ' ,
215
+ [ ' name ' => ' test_date ', ' config ' => [ ' dataType ' => ' multiselect ' ]] ,
186
216
['test_date ' => 'some_value ' ],
187
- [ ' eq ' => ' some_value ' ],
217
+ ' finset '
188
218
],
189
219
];
190
220
}
0 commit comments