@@ -12,20 +12,31 @@ class AbstractTest extends \PHPUnit\Framework\TestCase
12
12
*/
13
13
protected $ _model ;
14
14
15
+ /**
16
+ * @var \Magento\TestFramework\ObjectManager
17
+ */
18
+ private $ objectManager ;
19
+
15
20
/**
16
21
* On product import abstract class methods level it doesn't matter what product type is using.
17
22
* That is why current tests are using simple product entity type by default
18
23
*/
19
24
protected function setUp ()
20
25
{
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 ' ];
23
28
$ this ->_model = $ this ->getMockForAbstractClass (
24
29
\Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::class,
25
30
[
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
+ ),
29
40
$ params
30
41
]
31
42
);
@@ -130,6 +141,11 @@ public function prepareAttributesWithDefaultValueForSaveDataProvider()
130
141
}
131
142
132
143
/**
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
133
149
* @dataProvider clearEmptyDataDataProvider
134
150
*/
135
151
public function testClearEmptyData ($ rowData , $ expectedAttributes )
@@ -141,8 +157,14 @@ public function testClearEmptyData($rowData, $expectedAttributes)
141
157
}
142
158
}
143
159
160
+ /**
161
+ * Data provider for testClearEmptyData.
162
+ *
163
+ * @return array
164
+ */
144
165
public function clearEmptyDataDataProvider ()
145
166
{
167
+ // We use sku attribute to test static attributes.
146
168
return [
147
169
[
148
170
[
@@ -152,33 +174,57 @@ public function clearEmptyDataDataProvider()
152
174
'product_type ' => 'simple ' ,
153
175
'name ' => 'Simple 01 ' ,
154
176
'price ' => 10 ,
177
+ 'test_attribute ' => '1 ' ,
155
178
],
156
179
[
157
180
'sku ' => 'simple1 ' ,
158
181
'store_view_code ' => '' ,
159
182
'_attribute_set ' => 'Default ' ,
160
183
'product_type ' => 'simple ' ,
161
184
'name ' => 'Simple 01 ' ,
162
- 'price ' => 10
185
+ 'price ' => 10 ,
186
+ 'test_attribute ' => '1 ' ,
163
187
],
164
188
],
165
189
[
166
190
[
167
- 'sku ' => '' ,
168
- 'store_view_code ' => 'German ' ,
191
+ 'sku ' => '0 ' ,
192
+ 'store_view_code ' => '' ,
169
193
'_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 ' ,
173
198
],
174
199
[
175
- 'sku ' => '' ,
176
- 'store_view_code ' => 'German ' ,
200
+ 'sku ' => '0 ' ,
201
+ 'store_view_code ' => '' ,
177
202
'_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
+ ],
182
228
];
183
229
}
184
230
}
0 commit comments