33 private $objectManagerHelper;
38 private $scopeResolver;
48 private $connectionMock;
53 private $abstractAttribute;
63 private $attributeResource;
68 private $optionSelectBuilder;
72 $this->select = $this->getMockBuilder(Select::class)
74 ->disableOriginalConstructor()
77 $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
78 ->disableOriginalConstructor()
79 ->getMockForAbstractClass();
81 $this->scope = $this->getMockBuilder(ScopeInterface::class)
82 ->disableOriginalConstructor()
83 ->getMockForAbstractClass();
85 $this->scopeResolver = $this->getMockBuilder(ScopeResolverInterface::class)
86 ->disableOriginalConstructor()
87 ->getMockForAbstractClass();
89 $this->attributeResource = $this->getMockBuilder(Attribute::class)
90 ->disableOriginalConstructor()
93 $this->optionSelectBuilder = $this->getMockBuilder(OptionSelectBuilderInterface::class)
94 ->disableOriginalConstructor()
95 ->getMockForAbstractClass();
97 $this->abstractAttribute = $this->getMockBuilder(AbstractAttribute::class)
98 ->setMethods([
'getSourceModel',
'getSource'])
99 ->disableOriginalConstructor()
100 ->getMockForAbstractClass();
102 $this->objectManagerHelper =
new ObjectManagerHelper($this);
103 $this->model = $this->objectManagerHelper->getObject(
104 AttributeOptionProvider::class,
106 'attributeResource' => $this->attributeResource,
107 'scopeResolver' => $this->scopeResolver,
108 'optionSelectBuilder' => $this->optionSelectBuilder,
119 $this->scopeResolver->expects($this->any())
121 ->willReturn($this->scope);
123 $this->optionSelectBuilder->expects($this->any())
124 ->method(
'getSelect')
125 ->with($this->abstractAttribute, 4, $this->scope)
126 ->willReturn($this->select);
128 $this->attributeResource->expects($this->once())
129 ->method(
'getConnection')
130 ->willReturn($this->connectionMock);
132 $this->connectionMock->expects($this->once())
134 ->with($this->select)
139 $this->model->getAttributeOptions($this->abstractAttribute, 4)
149 $this->scopeResolver->expects($this->any())
151 ->willReturn($this->scope);
153 $source = $this->getMockBuilder(AbstractSource::class)
154 ->disableOriginalConstructor()
155 ->setMethods([
'getAllOptions'])
156 ->getMockForAbstractClass();
157 $source->expects($this->once())
158 ->method(
'getAllOptions')
160 [
'value' => 13,
'label' =>
'Option Value for index 13'],
161 [
'value' => 14,
'label' =>
'Option Value for index 14'],
162 [
'value' => 15,
'label' =>
'Option Value for index 15']
165 $this->abstractAttribute->expects($this->any())
166 ->method(
'getSource')
168 $this->abstractAttribute->expects($this->atLeastOnce())
169 ->method(
'getSourceModel')
170 ->willReturn(
'getSourceModel value');
172 $this->optionSelectBuilder->expects($this->any())
173 ->method(
'getSelect')
174 ->with($this->abstractAttribute, 1, $this->scope)
175 ->willReturn($this->select);
177 $this->attributeResource->expects($this->once())
178 ->method(
'getConnection')
179 ->willReturn($this->connectionMock);
181 $this->connectionMock->expects($this->once())
183 ->with($this->select)
188 $this->model->getAttributeOptions($this->abstractAttribute, 1)
201 'sku' =>
'Configurable1-Black',
203 'attribute_code' =>
'color',
204 'value_index' =>
'13',
205 'option_title' =>
'Black',
208 'sku' =>
'Configurable1-White',
210 'attribute_code' =>
'color',
211 'value_index' =>
'14',
212 'option_title' =>
'White',
215 'sku' =>
'Configurable1-Red',
217 'attribute_code' =>
'color',
218 'value_index' =>
'15',
219 'option_title' =>
'Red',
235 'sku' =>
'Configurable1-Black',
237 'attribute_code' =>
'color',
238 'value_index' =>
'13',
239 'option_title' =>
'Option Value for index 13',
240 'default_title' =>
'Option Value for index 13',
243 'sku' =>
'Configurable1-White',
245 'attribute_code' =>
'color',
246 'value_index' =>
'14',
247 'option_title' =>
'Option Value for index 14',
248 'default_title' =>
'Option Value for index 14',
251 'sku' =>
'Configurable1-Red',
253 'attribute_code' =>
'color',
254 'value_index' =>
'15',
255 'option_title' =>
'Option Value for index 15',
256 'default_title' =>
'Option Value for index 15',
optionsWithBackendModelDataProvider()
testGetAttributeOptionsWithBackendModel(array $options)
testGetAttributeOptions(array $options)
getAttributeOptionsDataProvider()