6
6
namespace Magento \CatalogImportExport \Model ;
7
7
8
8
use Magento \Framework \App \Bootstrap ;
9
- use Magento \Framework \App \Config ;
10
9
use Magento \Framework \App \Filesystem \DirectoryList ;
11
10
12
11
/**
16
15
*/
17
16
abstract class AbstractProductExportImportTestCase extends \PHPUnit \Framework \TestCase
18
17
{
19
- /**
20
- * @var \Magento\CatalogImportExport\Model\Export\Product
21
- */
22
- protected $ model ;
23
-
24
18
/**
25
19
* @var \Magento\Framework\ObjectManagerInterface
26
20
*/
@@ -61,8 +55,6 @@ abstract class AbstractProductExportImportTestCase extends \PHPUnit\Framework\Te
61
55
62
56
protected function setUp ()
63
57
{
64
- parent ::setUp ();
65
-
66
58
$ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
67
59
$ this ->fileSystem = $ this ->objectManager ->get (\Magento \Framework \Filesystem::class);
68
60
$ this ->productResource = $ this ->objectManager ->create (
@@ -262,9 +254,33 @@ public function testImportReplace($fixtures, $skus, $skippedAttributes = [])
262
254
}
263
255
264
256
/**
257
+ * @magentoAppArea adminhtml
258
+ * @magentoDbIsolation enabled
259
+ * @magentoAppIsolation enabled
260
+ *
261
+ * @param array $fixtures
262
+ * @param string[] $skus
263
+ * @param string[] $skippedAttributes
264
+ * @dataProvider importReplaceDataProvider
265
+ */
266
+ public function testImportReplaceWithPagination ($ fixtures , $ skus , $ skippedAttributes = [])
267
+ {
268
+ $ this ->fixtures = $ fixtures ;
269
+ $ this ->executeFixtures ($ fixtures , $ skus );
270
+ $ this ->modifyData ($ skus );
271
+ $ skippedAttributes = array_merge (self ::$ skippedAttributes , $ skippedAttributes );
272
+ $ this ->executeImportReplaceTest ($ skus , $ skippedAttributes , true );
273
+ }
274
+
275
+ /**
276
+ * @param string[] $skus
277
+ * @param string[] $skippedAttributes
278
+ * @param bool $usePagination
279
+ *
265
280
* @SuppressWarnings(PHPMD.NPathComplexity)
281
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
266
282
*/
267
- protected function executeImportReplaceTest ($ skus , $ skippedAttributes )
283
+ protected function executeImportReplaceTest ($ skus , $ skippedAttributes, $ usePagination = false )
268
284
{
269
285
$ replacedAttributes = [
270
286
'row_id ' ,
@@ -285,7 +301,18 @@ protected function executeImportReplaceTest($skus, $skippedAttributes)
285
301
$ index ++;
286
302
}
287
303
288
- $ csvfile = $ this ->exportProducts ();
304
+ $ exportProduct = $ this ->objectManager ->create (\Magento \CatalogImportExport \Model \Export \Product::class);
305
+ if ($ usePagination ) {
306
+ /** @var \ReflectionProperty $itemsPerPageProperty */
307
+ $ itemsPerPageProperty = $ this ->objectManager ->create (\ReflectionProperty::class, [
308
+ 'class ' => \Magento \CatalogImportExport \Model \Export \Product::class,
309
+ 'name ' => '_itemsPerPage '
310
+ ]);
311
+ $ itemsPerPageProperty ->setAccessible (true );
312
+ $ itemsPerPageProperty ->setValue ($ exportProduct , 1 );
313
+ }
314
+
315
+ $ csvfile = $ this ->exportProducts ($ exportProduct );
289
316
$ this ->importProducts ($ csvfile , \Magento \ImportExport \Model \Import::BEHAVIOR_REPLACE );
290
317
291
318
while ($ index > 0 ) {
@@ -326,13 +353,16 @@ protected function executeImportReplaceTest($skus, $skippedAttributes)
326
353
/**
327
354
* Export products in the system
328
355
*
356
+ * @param \Magento\CatalogImportExport\Model\Export\Product|null $exportProduct
329
357
* @return string Return exported file name
330
358
*/
331
- private function exportProducts ()
359
+ private function exportProducts (\ Magento \ CatalogImportExport \ Model \ Export \ Product $ exportProduct = null )
332
360
{
333
361
$ csvfile = uniqid ('importexport_ ' ) . '.csv ' ;
334
362
335
- $ exportProduct = $ this ->objectManager ->create (\Magento \CatalogImportExport \Model \Export \Product::class);
363
+ $ exportProduct = $ exportProduct ?: $ this ->objectManager ->create (
364
+ \Magento \CatalogImportExport \Model \Export \Product::class
365
+ );
336
366
$ exportProduct ->setWriter (
337
367
\Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
338
368
\Magento \ImportExport \Model \Export \Adapter \Csv::class,
0 commit comments