Skip to content

Commit b30d1b8

Browse files
Merge branch 'MAGNIMEX-260-UNIT-TESTS-attachAttributesById' into 'master'
Magnimex 260 unit tests - attachAttributesById Adjust arguments to cover attachAttributesById See merge request !147
2 parents 6fd5e0f + 97de1e9 commit b30d1b8

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ protected function setUp()
9090
);
9191
$attrCollection = $this->getMock(
9292
'\Magento\Eav\Model\Resource\Entity\Attribute\Collection',
93-
[],
93+
[
94+
'addFieldToFilter',
95+
],
9496
[],
9597
'',
9698
false
@@ -116,6 +118,10 @@ protected function setUp()
116118
false
117119
);
118120

121+
$entityAttributes = [
122+
'attribute_id' => 'attributeSetName'
123+
];
124+
119125
$this->entityModel->expects($this->any())->method('getEntityTypeId')->willReturn(3);
120126
$this->entityModel->expects($this->any())->method('getAttributeOptions')->willReturn(['option1', 'option2']);
121127
$attrSetColFactory->expects($this->any())->method('create')->willReturn($attrSetCollection);
@@ -136,7 +142,16 @@ protected function setUp()
136142
$attribute->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
137143
$attribute->expects($this->any())->method('usesSource')->willReturn(true);
138144
$attribute->expects($this->any())->method('getFrontendInput')->willReturn('multiselect');
139-
145+
$attrCollection
146+
->expects($this->any())
147+
->method('addFieldToFilter')
148+
->with(
149+
'main_table.attribute_id',
150+
['in' => [
151+
key($entityAttributes)
152+
]]
153+
)
154+
->willReturn([$attribute]);
140155

141156
$this->connection = $this->getMock(
142157
'Magento\Framework\DB\Adapter\Pdo\Mysql',
@@ -175,7 +190,10 @@ protected function setUp()
175190
$this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
176191
$this->connection->expects($this->any())->method('delete')->willReturnSelf();
177192
$this->connection->expects($this->any())->method('quoteInto')->willReturn('');
178-
$this->connection->expects($this->any())->method('fetchPairs')->will($this->returnValue([]));
193+
$this->connection
194+
->expects($this->any())
195+
->method('fetchPairs')
196+
->will($this->returnValue($entityAttributes));
179197

180198
$this->resource = $this->getMock(
181199
'\Magento\Framework\App\Resource',

0 commit comments

Comments
 (0)