Skip to content

Commit ef80980

Browse files
author
Yurii Hryhoriev
committed
MAGETWO-52775: [Github] Updating products with Multiple Select Attribute #4346 #4312
1 parent ce3223e commit ef80980

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ public function testGetComponentName()
9797
/**
9898
* Run test prepare method
9999
*
100-
* @param string $name
100+
* @param array $data
101101
* @param array $filterData
102102
* @param array|null $expectedCondition
103103
* @dataProvider getPrepareDataProvider
104104
* @return void
105105
*/
106-
public function testPrepare($name, $filterData, $expectedCondition)
106+
public function testPrepare($data, $filterData, $expectedCondition)
107107
{
108+
$name = $data['name'];
108109
/** @var UiComponentInterface $uiComponent */
109110
$uiComponent = $this->getMockForAbstractClass(
110111
'Magento\Framework\View\Element\UiComponentInterface',
@@ -124,13 +125,12 @@ public function testPrepare($name, $filterData, $expectedCondition)
124125
->method('addComponentDefinition')
125126
->with(Select::NAME, ['extends' => Select::NAME]);
126127
$this->contextMock->expects($this->any())
127-
->method('getRequestParam')
128-
->with(AbstractFilter::FILTER_VAR)
128+
->method('getFiltersParams')
129129
->willReturn($filterData);
130130
/** @var DataProviderInterface $dataProvider */
131131
$dataProvider = $this->getMockForAbstractClass(
132132
'Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface',
133-
[],
133+
['addFilter'],
134134
'',
135135
false
136136
);
@@ -139,9 +139,24 @@ public function testPrepare($name, $filterData, $expectedCondition)
139139
->willReturn($dataProvider);
140140

141141
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);
142157
$dataProvider->expects($this->any())
143158
->method('addFilter')
144-
->with($expectedCondition, $name);
159+
->with($filterMock);
145160
}
146161

147162
/** @var \Magento\Framework\Data\OptionSourceInterface $selectOptions */
@@ -164,7 +179,7 @@ public function testPrepare($name, $filterData, $expectedCondition)
164179
$this->filterModifierMock,
165180
$selectOptions,
166181
[],
167-
['name' => $name]
182+
$data
168183
);
169184

170185
$date->prepare();
@@ -177,14 +192,29 @@ public function getPrepareDataProvider()
177192
{
178193
return [
179194
[
180-
'test_date',
195+
['name' => 'test_date', 'config' => []],
196+
[],
197+
null
198+
],
199+
[
200+
['name' => 'test_date', 'config' => []],
181201
['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'
183213
],
184214
[
185-
'test_date',
215+
['name' => 'test_date', 'config' => ['dataType' => 'multiselect']],
186216
['test_date' => 'some_value'],
187-
['eq' => 'some_value'],
217+
'finset'
188218
],
189219
];
190220
}

0 commit comments

Comments
 (0)