@@ -12,20 +12,25 @@ 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 (\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),
29
34
$ params
30
35
]
31
36
);
@@ -130,6 +135,11 @@ public function prepareAttributesWithDefaultValueForSaveDataProvider()
130
135
}
131
136
132
137
/**
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
133
143
* @dataProvider clearEmptyDataDataProvider
134
144
*/
135
145
public function testClearEmptyData ($ rowData , $ expectedAttributes )
@@ -141,8 +151,14 @@ public function testClearEmptyData($rowData, $expectedAttributes)
141
151
}
142
152
}
143
153
154
+ /**
155
+ * Data provider for testClearEmptyData.
156
+ *
157
+ * @return array
158
+ */
144
159
public function clearEmptyDataDataProvider ()
145
160
{
161
+ // We use sku attribute to test static attributes.
146
162
return [
147
163
[
148
164
[
@@ -152,33 +168,57 @@ public function clearEmptyDataDataProvider()
152
168
'product_type ' => 'simple ' ,
153
169
'name ' => 'Simple 01 ' ,
154
170
'price ' => 10 ,
171
+ 'test_attribute ' => '1 ' ,
155
172
],
156
173
[
157
174
'sku ' => 'simple1 ' ,
158
175
'store_view_code ' => '' ,
159
176
'_attribute_set ' => 'Default ' ,
160
177
'product_type ' => 'simple ' ,
161
178
'name ' => 'Simple 01 ' ,
162
- 'price ' => 10
179
+ 'price ' => 10 ,
180
+ 'test_attribute ' => '1 ' ,
163
181
],
164
182
],
165
183
[
166
184
[
167
- 'sku ' => '' ,
168
- 'store_view_code ' => 'German ' ,
185
+ 'sku ' => '0 ' ,
186
+ 'store_view_code ' => '' ,
169
187
'_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 ' ,
173
192
],
174
193
[
175
- 'sku ' => '' ,
176
- 'store_view_code ' => 'German ' ,
194
+ 'sku ' => '0 ' ,
195
+ 'store_view_code ' => '' ,
177
196
'_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
+ ],
182
222
];
183
223
}
184
224
}
0 commit comments