@@ -12,20 +12,31 @@ class AbstractTest extends \PHPUnit\Framework\TestCase
1212 */
1313 protected $ _model ;
1414
15+ /**
16+ * @var \Magento\TestFramework\ObjectManager
17+ */
18+ private $ objectManager ;
19+
1520 /**
1621 * On product import abstract class methods level it doesn't matter what product type is using.
1722 * That is why current tests are using simple product entity type by default
1823 */
1924 protected function setUp ()
2025 {
21- $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
22- $ params = [$ objectManager ->create (\Magento \CatalogImportExport \Model \Import \Product::class), 'simple ' ];
26+ $ this -> objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
27+ $ params = [$ this -> objectManager ->create (\Magento \CatalogImportExport \Model \Import \Product::class), 'simple ' ];
2328 $ this ->_model = $ this ->getMockForAbstractClass (
2429 \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::class,
2530 [
26- $ objectManager ->get (\Magento \Eav \Model \ResourceModel \Entity \Attribute \Set \CollectionFactory::class),
27- $ objectManager ->get (\Magento \Catalog \Model \ResourceModel \Product \Attribute \CollectionFactory::class),
28- $ objectManager ->get (\Magento \Framework \App \ResourceConnection::class),
31+ $ this ->objectManager ->get (
32+ \Magento \Eav \Model \ResourceModel \Entity \Attribute \Set \CollectionFactory::class
33+ ),
34+ $ this ->objectManager ->get (
35+ \Magento \Catalog \Model \ResourceModel \Product \Attribute \CollectionFactory::class
36+ ),
37+ $ this ->objectManager ->get (
38+ \Magento \Framework \App \ResourceConnection::class
39+ ),
2940 $ params
3041 ]
3142 );
@@ -130,6 +141,11 @@ public function prepareAttributesWithDefaultValueForSaveDataProvider()
130141 }
131142
132143 /**
144+ * Test cleaning imported attribute data from empty values (note '0' is not empty).
145+ *
146+ * @magentoDbIsolation enabled
147+ * @magentoAppIsolation enabled
148+ * @magentoDataFixture Magento/CatalogImportExport/Model/Import/_files/custom_attributes.php
133149 * @dataProvider clearEmptyDataDataProvider
134150 */
135151 public function testClearEmptyData ($ rowData , $ expectedAttributes )
@@ -141,8 +157,14 @@ public function testClearEmptyData($rowData, $expectedAttributes)
141157 }
142158 }
143159
160+ /**
161+ * Data provider for testClearEmptyData.
162+ *
163+ * @return array
164+ */
144165 public function clearEmptyDataDataProvider ()
145166 {
167+ // We use sku attribute to test static attributes.
146168 return [
147169 [
148170 [
@@ -152,33 +174,57 @@ public function clearEmptyDataDataProvider()
152174 'product_type ' => 'simple ' ,
153175 'name ' => 'Simple 01 ' ,
154176 'price ' => 10 ,
177+ 'test_attribute ' => '1 ' ,
155178 ],
156179 [
157180 'sku ' => 'simple1 ' ,
158181 'store_view_code ' => '' ,
159182 '_attribute_set ' => 'Default ' ,
160183 'product_type ' => 'simple ' ,
161184 'name ' => 'Simple 01 ' ,
162- 'price ' => 10
185+ 'price ' => 10 ,
186+ 'test_attribute ' => '1 ' ,
163187 ],
164188 ],
165189 [
166190 [
167- 'sku ' => '' ,
168- 'store_view_code ' => 'German ' ,
191+ 'sku ' => '0 ' ,
192+ 'store_view_code ' => '' ,
169193 '_attribute_set ' => 'Default ' ,
170- 'product_type ' => '' ,
171- 'name ' => 'Simple 01 German ' ,
172- 'price ' => '' ,
194+ 'product_type ' => 'simple ' ,
195+ 'name ' => 'Simple 01 ' ,
196+ 'price ' => 10 ,
197+ 'test_attribute ' => '0 ' ,
173198 ],
174199 [
175- 'sku ' => '' ,
176- 'store_view_code ' => 'German ' ,
200+ 'sku ' => '0 ' ,
201+ 'store_view_code ' => '' ,
177202 '_attribute_set ' => 'Default ' ,
178- 'product_type ' => '' ,
179- 'name ' => 'Simple 01 German '
180- ]
181- ]
203+ 'product_type ' => 'simple ' ,
204+ 'name ' => 'Simple 01 ' ,
205+ 'price ' => 10 ,
206+ 'test_attribute ' => '0 ' ,
207+ ],
208+ ],
209+ [
210+ [
211+ 'sku ' => null ,
212+ 'store_view_code ' => '' ,
213+ '_attribute_set ' => 'Default ' ,
214+ 'product_type ' => 'simple ' ,
215+ 'name ' => 'Simple 01 ' ,
216+ 'price ' => 10 ,
217+ 'test_attribute ' => null ,
218+ ],
219+ [
220+ 'sku ' => null ,
221+ 'store_view_code ' => '' ,
222+ '_attribute_set ' => 'Default ' ,
223+ 'product_type ' => 'simple ' ,
224+ 'name ' => 'Simple 01 ' ,
225+ 'price ' => 10 ,
226+ ],
227+ ],
182228 ];
183229 }
184230}
0 commit comments