30 private $objectManagerHelper;
35 private $attributeResourceMock;
40 private $attributeOptionProviderMock;
50 private $connectionMock;
55 private $abstractAttributeMock;
64 $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
65 ->setMethods([
'select',
'getIfNullSql'])
66 ->disableOriginalConstructor()
67 ->getMockForAbstractClass();
68 $this->select = $this->getMockBuilder(Select::class)
69 ->setMethods([
'from',
'joinInner',
'joinLeft',
'where',
'columns',
'order'])
70 ->disableOriginalConstructor()
72 $this->connectionMock->expects($this->atLeastOnce())
73 ->method(
'select',
'getIfNullSql')
74 ->willReturn($this->select);
76 $this->attributeResourceMock = $this->getMockBuilder(Attribute::class)
77 ->setMethods([
'getTable',
'getConnection'])
78 ->disableOriginalConstructor()
80 $this->attributeResourceMock->expects($this->atLeastOnce())
81 ->method(
'getConnection')
82 ->willReturn($this->connectionMock);
84 $this->attributeOptionProviderMock = $this->getMockBuilder(OptionProvider::class)
85 ->setMethods([
'getProductEntityLinkField'])
86 ->disableOriginalConstructor()
89 $this->abstractAttributeMock = $this->getMockBuilder(AbstractAttribute::class)
90 ->setMethods([
'getBackendTable',
'getAttributeId',
'getSourceModel'])
91 ->disableOriginalConstructor()
92 ->getMockForAbstractClass();
94 $this->scope = $this->getMockBuilder(ScopeInterface::class)
95 ->disableOriginalConstructor()
96 ->getMockForAbstractClass();
98 $this->objectManagerHelper =
new ObjectManagerHelper($this);
99 $this->model = $this->objectManagerHelper->getObject(
100 OptionSelectBuilder::class,
102 'attributeResource' => $this->attributeResourceMock,
103 'attributeOptionProvider' => $this->attributeOptionProviderMock,
113 $this->select->expects($this->exactly(1))->method(
'from')->willReturnSelf();
114 $this->select->expects($this->exactly(1))->method(
'columns')->willReturnSelf();
115 $this->select->expects($this->exactly(5))->method(
'joinInner')->willReturnSelf();
116 $this->select->expects($this->exactly(4))->method(
'joinLeft')->willReturnSelf();
117 $this->select->expects($this->exactly(1))->method(
'order')->willReturnSelf();
118 $this->select->expects($this->exactly(2))->method(
'where')->willReturnSelf();
120 $this->attributeResourceMock->expects($this->exactly(9))
123 $this->returnValueMap(
125 [
'catalog_product_super_attribute',
'catalog_product_super_attribute value'],
126 [
'catalog_product_entity',
'catalog_product_entity value'],
127 [
'catalog_product_super_link',
'catalog_product_super_link value'],
128 [
'eav_attribute',
'eav_attribute value'],
129 [
'catalog_product_entity',
'catalog_product_entity value'],
130 [
'catalog_product_super_attribute_label',
'catalog_product_super_attribute_label value'],
131 [
'eav_attribute_option',
'eav_attribute_option value'],
132 [
'eav_attribute_option_value',
'eav_attribute_option_value value']
137 $this->abstractAttributeMock->expects($this->atLeastOnce())
138 ->method(
'getAttributeId')
139 ->willReturn(
'getAttributeId value');
140 $this->abstractAttributeMock->expects($this->atLeastOnce())
141 ->method(
'getBackendTable')
142 ->willReturn(
'getMainTable value');
144 $this->scope->expects($this->any())->method(
'getId')->willReturn(123);
148 $this->model->getSelect($this->abstractAttributeMock, 4, $this->scope)
157 $this->select->expects($this->exactly(1))->method(
'from')->willReturnSelf();
158 $this->select->expects($this->exactly(0))->method(
'columns')->willReturnSelf();
159 $this->select->expects($this->exactly(5))->method(
'joinInner')->willReturnSelf();
160 $this->select->expects($this->exactly(2))->method(
'joinLeft')->willReturnSelf();
161 $this->select->expects($this->exactly(1))->method(
'order')->willReturnSelf();
162 $this->select->expects($this->exactly(2))->method(
'where')->willReturnSelf();
164 $this->attributeResourceMock->expects($this->exactly(7))
167 $this->returnValueMap(
169 [
'catalog_product_super_attribute',
'catalog_product_super_attribute value'],
170 [
'catalog_product_entity',
'catalog_product_entity value'],
171 [
'catalog_product_super_link',
'catalog_product_super_link value'],
172 [
'eav_attribute',
'eav_attribute value'],
173 [
'catalog_product_entity',
'catalog_product_entity value'],
174 [
'catalog_product_super_attribute_label',
'catalog_product_super_attribute_label value'],
175 [
'eav_attribute_option',
'eav_attribute_option value']
180 $this->abstractAttributeMock->expects($this->atLeastOnce())
181 ->method(
'getAttributeId')
182 ->willReturn(
'getAttributeId value');
183 $this->abstractAttributeMock->expects($this->atLeastOnce())
184 ->method(
'getBackendTable')
185 ->willReturn(
'getMainTable value');
186 $this->abstractAttributeMock->expects($this->atLeastOnce())
187 ->method(
'getSourceModel')
188 ->willReturn(
'source model value');
190 $this->scope->expects($this->any())->method(
'getId')->willReturn(123);
194 $this->model->getSelect($this->abstractAttributeMock, 4, $this->scope)
testGetSelectWithBackendModel()