@@ -12,20 +12,25 @@ 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 (\Magento \Eav \Model \ResourceModel \Entity \Attribute \Set \CollectionFactory::class),
32+ $ this -> objectManager ->get (\Magento \Catalog \Model \ResourceModel \Product \Attribute \CollectionFactory::class),
33+ $ this -> objectManager ->get (\Magento \Framework \App \ResourceConnection::class),
2934 $ params
3035 ]
3136 );
@@ -130,6 +135,11 @@ public function prepareAttributesWithDefaultValueForSaveDataProvider()
130135 }
131136
132137 /**
138+ * Test cleaning imported attribute data from empty values (note '0' is not empty).
139+ *
140+ * @magentoDbIsolation enabled
141+ * @magentoAppIsolation enabled
142+ * @magentoDataFixture Magento/CatalogImportExport/Model/Import/_files/custom_attributes.php
133143 * @dataProvider clearEmptyDataDataProvider
134144 */
135145 public function testClearEmptyData ($ rowData , $ expectedAttributes )
@@ -141,8 +151,14 @@ public function testClearEmptyData($rowData, $expectedAttributes)
141151 }
142152 }
143153
154+ /**
155+ * Data provider for testClearEmptyData.
156+ *
157+ * @return array
158+ */
144159 public function clearEmptyDataDataProvider ()
145160 {
161+ // We use sku attribute to test static attributes.
146162 return [
147163 [
148164 [
@@ -152,33 +168,57 @@ public function clearEmptyDataDataProvider()
152168 'product_type ' => 'simple ' ,
153169 'name ' => 'Simple 01 ' ,
154170 'price ' => 10 ,
171+ 'test_attribute ' => '1 ' ,
155172 ],
156173 [
157174 'sku ' => 'simple1 ' ,
158175 'store_view_code ' => '' ,
159176 '_attribute_set ' => 'Default ' ,
160177 'product_type ' => 'simple ' ,
161178 'name ' => 'Simple 01 ' ,
162- 'price ' => 10
179+ 'price ' => 10 ,
180+ 'test_attribute ' => '1 ' ,
163181 ],
164182 ],
165183 [
166184 [
167- 'sku ' => '' ,
168- 'store_view_code ' => 'German ' ,
185+ 'sku ' => '0 ' ,
186+ 'store_view_code ' => '' ,
169187 '_attribute_set ' => 'Default ' ,
170- 'product_type ' => '' ,
171- 'name ' => 'Simple 01 German ' ,
172- 'price ' => '' ,
188+ 'product_type ' => 'simple ' ,
189+ 'name ' => 'Simple 01 ' ,
190+ 'price ' => 10 ,
191+ 'test_attribute ' => '0 ' ,
173192 ],
174193 [
175- 'sku ' => '' ,
176- 'store_view_code ' => 'German ' ,
194+ 'sku ' => '0 ' ,
195+ 'store_view_code ' => '' ,
177196 '_attribute_set ' => 'Default ' ,
178- 'product_type ' => '' ,
179- 'name ' => 'Simple 01 German '
180- ]
181- ]
197+ 'product_type ' => 'simple ' ,
198+ 'name ' => 'Simple 01 ' ,
199+ 'price ' => 10 ,
200+ 'test_attribute ' => '0 ' ,
201+ ],
202+ ],
203+ [
204+ [
205+ 'sku ' => null ,
206+ 'store_view_code ' => '' ,
207+ '_attribute_set ' => 'Default ' ,
208+ 'product_type ' => 'simple ' ,
209+ 'name ' => 'Simple 01 ' ,
210+ 'price ' => 10 ,
211+ 'test_attribute ' => null ,
212+ ],
213+ [
214+ 'sku ' => null ,
215+ 'store_view_code ' => '' ,
216+ '_attribute_set ' => 'Default ' ,
217+ 'product_type ' => 'simple ' ,
218+ 'name ' => 'Simple 01 ' ,
219+ 'price ' => 10 ,
220+ ],
221+ ],
182222 ];
183223 }
184224}
0 commit comments