59 $this->directory = $this->getMockBuilder(\
Magento\Framework\
Filesystem\Directory\WriteInterface::class)
60 ->getMockForAbstractClass();
62 $this->filesystem = $this->getMockBuilder(\
Magento\Framework\Filesystem::class)
63 ->disableOriginalConstructor()
65 $this->filesystem->expects($this->any())
66 ->method(
'getDirectoryWrite')
68 ->willReturn($this->directory);
70 $this->filter = $this->getMockBuilder(\
Magento\Ui\Component\MassAction\Filter::class)
71 ->disableOriginalConstructor()
74 $this->metadataProvider = $this->getMockBuilder(\
Magento\Ui\Model\Export\MetadataProvider::class)
75 ->disableOriginalConstructor()
78 $this->component = $this->getMockBuilder(\
Magento\Framework\View\Element\UiComponentInterface::class)
79 ->getMockForAbstractClass();
81 $this->stream = $this->getMockBuilder(\
Magento\Framework\
Filesystem\File\WriteInterface::class)
87 ->getMockForAbstractClass();
92 $this->metadataProvider
98 $componentName =
'component_name';
99 $data = [
'data_value'];
101 $document = $this->getMockBuilder(\
Magento\Framework\Api\Search\DocumentInterface::class)
102 ->getMockForAbstractClass();
108 $this->stream->expects($this->once())
111 $this->stream->expects($this->once())
114 $this->stream->expects($this->once())
117 $this->stream->expects($this->any())
122 $this->metadataProvider->expects($this->once())
123 ->method(
'getOptions')
125 $this->metadataProvider->expects($this->once())
126 ->method(
'getHeaders')
127 ->with($this->component)
129 $this->metadataProvider->expects($this->once())
130 ->method(
'getFields')
131 ->with($this->component)
133 $this->metadataProvider->expects($this->once())
134 ->method(
'getRowData')
135 ->with($document, [], [])
137 $this->metadataProvider->expects($this->once())
138 ->method(
'convertDate')
139 ->with($document, $componentName);
141 $result = $this->model->getCsvFile();
142 $this->assertTrue(is_array(
$result));
143 $this->assertArrayHasKey(
'type',
$result);
144 $this->assertArrayHasKey(
'value',
$result);
145 $this->assertArrayHasKey(
'rm',
$result);
146 $this->assertContains($componentName,
$result);
147 $this->assertContains(
'.csv',
$result);
155 $this->stream = $this->getMockBuilder(\
Magento\Framework\
Filesystem\File\WriteInterface::class)
161 ->getMockForAbstractClass();
163 $this->stream->expects($this->once())
166 $this->stream->expects($this->once())
169 $this->stream->expects($this->once())
172 $this->stream->expects($this->once())
184 $context = $this->getMockBuilder(\
Magento\Framework\View\Element\UiComponent\ContextInterface::class)
185 ->setMethods([
'getDataProvider'])
186 ->getMockForAbstractClass();
188 $dataProvider = $this->getMockBuilder(
191 ->setMethods([
'getSearchResult'])
192 ->getMockForAbstractClass();
194 $searchResult = $this->getMockBuilder(\
Magento\Framework\Api\Search\SearchResultInterface::class)
195 ->setMethods([
'getItems'])
196 ->getMockForAbstractClass();
199 ->setMethods([
'setPageSize',
'setCurrentPage'])
200 ->getMockForAbstractClass();
201 $this->component->expects($this->any())
203 ->willReturn($componentName);
204 $this->component->expects($this->once())
205 ->method(
'getContext')
206 ->willReturn($context);
208 $context->expects($this->once())
209 ->method(
'getDataProvider')
210 ->willReturn($dataProvider);
212 $dataProvider->expects($this->exactly(2))
213 ->method(
'getSearchResult')
214 ->willReturn($searchResult);
216 $dataProvider->expects($this->once())
217 ->method(
'getSearchCriteria')
220 $searchResult->expects($this->once())
224 $searchResult->expects($this->once())
225 ->method(
'getTotalCount')
229 ->method(
'setCurrentPage')
233 ->method(
'setPageSize')
240 $this->filter->expects($this->once())
241 ->method(
'getComponent')
242 ->willReturn($this->component);
243 $this->filter->expects($this->once())
244 ->method(
'prepareComponent')
245 ->with($this->component)
247 $this->filter->expects($this->once())
248 ->method(
'applySelectionOnTargetProvider')
254 $this->directory->expects($this->once())
258 $this->directory->expects($this->once())
260 ->willReturn($this->stream);
mockComponent($componentName, $items)