6 declare(strict_types=1);
16 as FieldTypeConverterInterface;
18 as IndexTypeConverterInterface;
22 as FieldIndexResolver;
42 private $fieldTypeConverter;
47 private $indexTypeConverter;
52 private $attributeAdapterProvider;
57 private $fieldIndexResolver;
62 private $fieldTypeResolver;
71 $this->eavConfig = $this->getMockBuilder(Config::class)
72 ->disableOriginalConstructor()
73 ->setMethods([
'getEntityAttributes'])
75 $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class)
76 ->disableOriginalConstructor()
77 ->getMockForAbstractClass();
78 $this->indexTypeConverter = $this->getMockBuilder(IndexTypeConverterInterface::class)
79 ->disableOriginalConstructor()
80 ->getMockForAbstractClass();
81 $this->attributeAdapterProvider = $this->getMockBuilder(AttributeProvider::class)
82 ->disableOriginalConstructor()
83 ->setMethods([
'getByAttributeCode'])
85 $this->fieldTypeResolver = $this->getMockBuilder(FieldTypeResolver::class)
86 ->disableOriginalConstructor()
87 ->setMethods([
'getFieldType'])
89 $this->fieldIndexResolver = $this->getMockBuilder(FieldIndexResolver::class)
90 ->disableOriginalConstructor()
91 ->setMethods([
'getFieldIndex'])
97 \
Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField::class,
99 'eavConfig' => $this->eavConfig,
100 'fieldTypeConverter' => $this->fieldTypeConverter,
101 'indexTypeConverter' => $this->indexTypeConverter,
102 'attributeAdapterProvider' => $this->attributeAdapterProvider,
103 'fieldIndexResolver' => $this->fieldIndexResolver,
104 'fieldTypeResolver' => $this->fieldTypeResolver,
127 $this->fieldTypeResolver->expects($this->any())
128 ->method(
'getFieldType')
129 ->willReturn($inputType);
130 $this->fieldIndexResolver->expects($this->any())
131 ->method(
'getFieldIndex')
132 ->willReturn($indexType);
133 $this->indexTypeConverter->expects($this->any())
137 $productAttributeMock = $this->getMockBuilder(AbstractAttribute::class)
138 ->setMethods([
'getAttributeCode'])
139 ->disableOriginalConstructor()
140 ->getMockForAbstractClass();
141 $productAttributeMock->expects($this->any())
142 ->method(
'getAttributeCode')
144 $this->eavConfig->expects($this->any())->method(
'getEntityAttributes')
145 ->willReturn([$productAttributeMock]);
147 $attributeMock = $this->getMockBuilder(AttributeAdapter::class)
148 ->disableOriginalConstructor()
149 ->setMethods([
'isComplexType',
'getAttributeCode'])
151 $attributeMock->expects($this->any())
152 ->method(
'isComplexType')
153 ->willReturn($isComplexType);
154 $attributeMock->expects($this->any())
155 ->method(
'getAttributeCode')
157 $this->attributeAdapterProvider->expects($this->any())
158 ->method(
'getByAttributeCode')
159 ->with($this->anything())
160 ->willReturn($attributeMock);
161 $this->fieldTypeConverter->expects($this->any())
163 ->with($this->anything())
164 ->will($this->returnCallback(
165 function (
$type) use ($complexType) {
166 static $callCount = [];
167 $callCount[
$type] = !isset($callCount[
$type]) ? 1 : ++$callCount[
$type];
169 if (
$type ===
'string') {
172 if (
$type ===
'string') {
184 $this->provider->getFields([
'storeId' => 1])
205 'category_ids_value' => [
elseif(isset( $params[ 'redirect_parent']))
testGetAllAttributesTypes( $attributeCode, $inputType, $indexType, $isComplexType, $complexType, $expected)