42 private $attributeContainerMock;
52 private $resourceIndex;
57 private $advancedSearchIndex;
62 private $fieldMapperMock;
67 private $dateTimeMock;
72 private $localeDateMock;
77 private $scopeConfigMock;
82 private $storeManagerMock;
87 private $storeInterface;
94 $this->builderMock = $this->getMockBuilder(\
Magento\Elasticsearch\Model\Adapter\Document\Builder::class)
95 ->setMethods([
'addField',
'addFields',
'build'])
96 ->disableOriginalConstructor()
99 $this->attributeContainerMock = $this->getMockBuilder(
100 \
Magento\Elasticsearch\Model\Adapter\Container\Attribute::class
101 )->setMethods([
'getAttribute',
'setStoreId',
'getBackendType',
'getFrontendInput'])
102 ->disableOriginalConstructor()
105 $this->resourceIndex = $this->getMockBuilder(\
Magento\Elasticsearch\Model\
ResourceModel\Index::class)
106 ->disableOriginalConstructor()
109 'getFullCategoryProductIndexData',
110 'getFullProductIndexData',
114 $this->fieldMapperMock = $this->getMockBuilder(\
Magento\Elasticsearch\Model\Adapter\FieldMapperInterface::class)
115 ->setMethods([
'getFieldName',
'getAllAttributesTypes'])
116 ->disableOriginalConstructor()
119 $this->dateTimeMock = $this->getMockBuilder(\
Magento\Framework\Stdlib\DateTime::class)
120 ->setMethods([
'isEmptyDate',
'setTimezone',
'format'])
121 ->disableOriginalConstructor()
124 $this->localeDateMock = $this->getMockBuilder(\
Magento\Framework\Stdlib\
DateTime\TimezoneInterface::class)
125 ->disableOriginalConstructor()
128 $this->scopeConfigMock = $this->getMockBuilder(\
Magento\Framework\
App\
Config\ScopeConfigInterface::class)
129 ->disableOriginalConstructor()
132 $this->storeManagerMock = $this->getMockBuilder(\
Magento\Store\Model\StoreManagerInterface::class)
133 ->disableOriginalConstructor()
136 $this->advancedSearchIndex = $this->getMockBuilder(\
Magento\AdvancedSearch\Model\
ResourceModel\Index::class)
137 ->disableOriginalConstructor()
140 $this->attribute = $this->getMockBuilder(\
Magento\Catalog\Model\
ResourceModel\Eav\Attribute::class)
141 ->disableOriginalConstructor()
144 $this->storeInterface = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
145 ->disableOriginalConstructor()
150 \
Magento\Elasticsearch\Model\Adapter\DataMapper\ProductDataMapper::class,
152 'builder' => $this->builderMock,
153 'attributeContainer' => $this->attributeContainerMock,
154 'resourceIndex' => $this->resourceIndex,
155 'fieldMapper' => $this->fieldMapperMock,
156 'dateTime' => $this->dateTimeMock,
157 'localeDate' => $this->localeDateMock,
158 'scopeConfig' => $this->scopeConfigMock,
159 'storeManager' => $this->storeManagerMock
179 $this->attributeContainerMock->expects($this->any())->method(
'getAttribute')->will(
180 $this->returnValue($this->attribute)
182 $this->resourceIndex->expects($this->any())
183 ->method(
'getPriceIndexData')
188 $this->resourceIndex->expects($this->any())
189 ->method(
'getFullCategoryProductIndexData')
194 'name' =>
'Default Category',
209 $this->storeManagerMock->expects($this->any())
211 ->willReturn($this->storeInterface);
212 $this->storeInterface->expects($this->any())
213 ->method(
'getWebsiteId')
215 $this->attributeContainerMock->expects($this->any())->method(
'setStoreId')->will(
216 $this->returnValue($this->attributeContainerMock)
218 $this->attribute->expects($this->any())->method(
'getBackendType')->will(
219 $this->returnValue(
$type)
221 $this->attribute->expects($this->any())->method(
'getFrontendInput')->will(
222 $this->returnValue($frontendInput)
224 $this->dateTimeMock->expects($this->any())->method(
'isEmptyDate')->will(
225 $this->returnValue($emptyDate)
227 $this->scopeConfigMock->expects($this->any())->method(
'getValue')->will(
228 $this->returnValue(
'Europe/London')
230 $this->builderMock->expects($this->any())->method(
'addField')->will(
231 $this->returnValue([])
233 $this->builderMock->expects($this->any())->method(
'addFields')->will(
234 $this->returnValue([])
236 $this->builderMock->expects($this->any())->method(
'build')->will(
237 $this->returnValue([])
240 $this->resourceIndex->expects($this->once())
241 ->method(
'getFullProductIndexData')
244 $this->assertInternalType(
259 [
'price'=>
'11',
'created_at'=>
'00-00-00 00:00:00',
'color_value'=>
'11'],
267 [
'price'=>
'11',
'created_at'=>
'00-00-00 00:00:00',
'color_value'=>
'11'],
275 [
'price'=>
'11',
'created_at'=>
null,
'color_value'=>
'11', ],
291 'website_price'=>
'1',
294 'created_at'=>
'00-00-00 00:00:00' 303 [
'image'=>
'11',
'created_at'=>
'00-00-00 00:00:00'],
313 'small_image' =>
'1',
315 'swatch_image' =>
'1',
321 'media_type'=>
'image',
332 'created_at'=>
'00-00-00 00:00:00' 343 'small_image' =>
'1',
345 'swatch_image' =>
'1',
351 'media_type'=>
'video',
362 'video_description'=>
'1',
363 'video_metadata'=>
'1',
364 'video_provider'=>
'1' 367 'created_at'=>
'00-00-00 00:00:00' 376 [
'quantity_and_stock_status'=>
'11',
'created_at'=>
'00-00-00 00:00:00'],
384 [
'quantity_and_stock_status'=>[
'is_in_stock' =>
'1',
'qty' =>
'12'],
'created_at'=>
'00-00-00 00:00:00'],
392 [
'price'=>
'11',
'created_at'=>
'1995-12-31 23:59:59',
'options'=>[
'value1',
'value2']],
testGetMap($productId, $productData, $storeId, $emptyDate, $type, $frontendInput)