41 private $localeResolver;
48 $this->filter = $this->getMockBuilder(\
Magento\Ui\Component\MassAction\Filter::class)
49 ->disableOriginalConstructor()
52 $this->localeDate = $this->getMockBuilder(\
Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)
53 ->disableOriginalConstructor()
56 $this->localeResolver = $this->getMockBuilder(\
Magento\Framework\Locale\ResolverInterface::class)
57 ->disableOriginalConstructor()
60 $this->localeResolver->expects($this->any())
66 \
Magento\Ui\Model\Export\MetadataProvider::class,
68 'filter' => $this->filter,
69 'localeDate' => $this->localeDate,
70 'localeResolver' => $this->localeResolver,
71 'data' => [
'component_name' => [
'field']],
84 $componentName =
'component_name';
85 $columnName =
'column_name';
87 $component = $this->prepareColumns($componentName, $columnName, $columnLabels[0]);
88 $result = $this->model->getHeaders($component);
89 $this->assertTrue(is_array(
$result));
91 $this->assertEquals($expected,
$result);
104 [[
'IDTEST'],[
'"IDTEST"']],
105 [[
'ID TEST'],[
'"ID TEST"']],
111 $componentName =
'component_name';
112 $columnName =
'column_name';
113 $columnLabel =
'column_label';
115 $component = $this->prepareColumns($componentName, $columnName, $columnLabel);
117 $result = $this->model->getFields($component);
118 $this->assertTrue(is_array(
$result));
119 $this->assertCount(1,
$result);
120 $this->assertEquals($columnName,
$result[0]);
131 protected function prepareColumns(
135 $columnActionsName =
'actions_name',
136 $columnActionsLabel =
'actions_label' 139 $component = $this->getMockBuilder(\
Magento\Framework\View\Element\UiComponentInterface::class)
140 ->getMockForAbstractClass();
143 $columns = $this->getMockBuilder(\
Magento\Ui\Component\Listing\Columns::class)
144 ->disableOriginalConstructor()
148 $column = $this->getMockBuilder(\
Magento\Ui\Component\Listing\
Columns\Column::class)
149 ->disableOriginalConstructor()
152 $columnActions = $this->getMockBuilder(\
Magento\Ui\Component\Listing\
Columns\Column::class)
153 ->disableOriginalConstructor()
156 $component->expects($this->any())
158 ->willReturn($componentName);
159 $component->expects($this->once())
160 ->method(
'getChildComponents')
164 ->method(
'getChildComponents')
165 ->willReturn([$column, $columnActions]);
167 $column->expects($this->any())
169 ->willReturn($columnName);
170 $column->expects($this->any())
174 [
'config/label',
null, $columnLabel],
175 [
'config/dataType',
null,
'data_type'],
179 $columnActions->expects($this->any())
181 ->willReturn($columnActionsName);
182 $columnActions->expects($this->any())
186 [
'config/label',
null, $columnActionsLabel],
187 [
'config/dataType',
null,
'actions'],
204 $document = $this->getMockBuilder(\
Magento\Framework\Api\Search\DocumentInterface::class)
205 ->getMockForAbstractClass();
207 $attribute = $this->getMockBuilder(\
Magento\Framework\Api\AttributeInterface::class)
208 ->getMockForAbstractClass();
210 $document->expects($this->once())
211 ->method(
'getCustomAttribute')
220 $this->assertTrue(is_array(
$result));
221 $this->assertCount(1,
$result);
222 $this->assertEquals($expected,
$result);
233 'fields' => [
'column'],
236 'key_1' =>
'value_1',
245 'fields' => [
'column'],
248 'key_1' =>
'value_1',
257 'fields' => [
'column'],
274 $component = $this->getMockBuilder(\
Magento\Framework\View\Element\UiComponentInterface::class)
275 ->getMockForAbstractClass();
277 $childComponent = $this->getMockBuilder(\
Magento\Framework\View\Element\UiComponentInterface::class)
278 ->getMockForAbstractClass();
281 ->disableOriginalConstructor()
284 $select = $this->getMockBuilder(\
Magento\Ui\Component\Filters\Type\Select::class)
285 ->disableOriginalConstructor()
288 $this->filter->expects($this->once())
289 ->method(
'getComponent')
290 ->willReturn($component);
292 $component->expects($this->once())
293 ->method(
'getChildComponents')
294 ->willReturn([
'listing_top' => $childComponent]);
296 $childComponent->expects($this->once())
297 ->method(
'getChildComponents')
301 ->method(
'getChildComponents')
306 ->willReturn($filter);
309 ->with(
'config/options')
312 $result = $this->model->getOptions();
313 $this->assertTrue(is_array(
$result));
314 $this->assertCount(1,
$result);
315 $this->assertEquals($expected,
$result);
325 'filter' =>
'filter_name',
328 'value' =>
'value_1',
329 'label' =>
'label_1',
334 'value_1' =>
'label_1',
339 'filter' =>
'filter_name',
344 'value' =>
'value_2',
345 'label' =>
'label_2',
348 'label' =>
'label_1',
353 'value_2' =>
'label_1label_2',
358 'filter' =>
'filter_name',
365 'value' =>
'value_3',
366 'label' =>
'label_3',
369 'label' =>
'label_2',
372 'label' =>
'label_1',
377 'value_3' =>
'label_1label_2label_3',
392 public function testConvertDate($fieldValue, $expected)
394 $componentName =
'component_name';
396 $document = $this->getMockBuilder(\
Magento\Framework\DataObject::class)
397 ->disableOriginalConstructor()
400 $document->expects($this->once())
403 ->willReturn($fieldValue);
405 $this->localeDate->expects($this->once())
407 ->willReturn(
new \DateTime($fieldValue,
new \DateTimeZone(
'UTC')));
409 $document->expects($this->once())
411 ->with(
'field', $expected);
413 $this->model->convertDate($document, $componentName);
425 'fieldValue' =>
'@1534505233',
426 'expected' =>
'Aug 17, 2018 11:27:13 AM',
429 'fieldValue' =>
'@1534530000',
430 'expected' =>
'Aug 17, 2018 06:20:00 PM',