@@ -84,8 +84,10 @@ protected function setUp()
84
84
/**
85
85
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php
86
86
* @magentoDbIsolation enabled
87
+ *
88
+ * @return void
87
89
*/
88
- public function testExport ()
90
+ public function testExport (): void
89
91
{
90
92
$ this ->model ->setWriter (
91
93
$ this ->objectManager ->create (
@@ -109,8 +111,10 @@ public function testExport()
109
111
/**
110
112
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data_special_chars.php
111
113
* @magentoDbIsolation enabled
114
+ *
115
+ * @return void
112
116
*/
113
- public function testExportSpecialChars ()
117
+ public function testExportSpecialChars (): void
114
118
{
115
119
$ this ->model ->setWriter (
116
120
$ this ->objectManager ->create (
@@ -125,8 +129,10 @@ public function testExportSpecialChars()
125
129
/**
126
130
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_product_links_data.php
127
131
* @magentoDbIsolation enabled
132
+ *
133
+ * @return void
128
134
*/
129
- public function testExportWithProductLinks ()
135
+ public function testExportWithProductLinks (): void
130
136
{
131
137
$ this ->model ->setWriter (
132
138
\Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
@@ -143,8 +149,10 @@ public function testExportWithProductLinks()
143
149
* @magentoDbIsolation enabled
144
150
* @covers \Magento\CatalogImportExport\Model\Export\Product::export
145
151
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php
152
+ *
153
+ * @return void
146
154
*/
147
- public function testExportStockItemAttributesAreFilled ()
155
+ public function testExportStockItemAttributesAreFilled (): void
148
156
{
149
157
$ this ->markTestSkipped ('Test needs to be skipped. ' );
150
158
$ fileWrite = $ this ->createMock (\Magento \Framework \Filesystem \File \Write::class);
@@ -176,8 +184,9 @@ public function testExportStockItemAttributesAreFilled()
176
184
* Verify header columns (that stock item attributes column headers are present)
177
185
*
178
186
* @param array $headerColumns
187
+ * @return void
179
188
*/
180
- public function verifyHeaderColumns (array $ headerColumns )
189
+ public function verifyHeaderColumns (array $ headerColumns ): void
181
190
{
182
191
foreach (self ::$ stockItemAttributes as $ stockItemAttribute ) {
183
192
$ this ->assertContains (
@@ -192,8 +201,9 @@ public function verifyHeaderColumns(array $headerColumns)
192
201
* Verify row data (stock item attribute values)
193
202
*
194
203
* @param array $rowData
204
+ * @return void
195
205
*/
196
- public function verifyRow (array $ rowData )
206
+ public function verifyRow (array $ rowData ): void
197
207
{
198
208
foreach (self ::$ stockItemAttributes as $ stockItemAttribute ) {
199
209
$ this ->assertNotSame (
@@ -208,8 +218,10 @@ public function verifyRow(array $rowData)
208
218
* Verifies if exception processing works properly
209
219
* @magentoDbIsolation enabled
210
220
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php
221
+ *
222
+ * @return void
211
223
*/
212
- public function testExceptionInGetExportData ()
224
+ public function testExceptionInGetExportData (): void
213
225
{
214
226
$ this ->markTestSkipped ('Test needs to be skipped. ' );
215
227
$ exception = new \Exception ('Error ' );
@@ -258,8 +270,10 @@ public function testExceptionInGetExportData()
258
270
* Verify if fields wrapping works correct when "Fields Enclosure" option enabled
259
271
*
260
272
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php
273
+ *
274
+ * @return void
261
275
*/
262
- public function testExportWithFieldsEnclosure ()
276
+ public function testExportWithFieldsEnclosure (): void
263
277
{
264
278
$ this ->model ->setParameters (
265
279
[
@@ -284,8 +298,10 @@ public function testExportWithFieldsEnclosure()
284
298
* Verify that "category ids" filter correctly applies to export result
285
299
*
286
300
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_categories.php
301
+ *
302
+ * @return void
287
303
*/
288
- public function testCategoryIdsFilter ()
304
+ public function testCategoryIdsFilter (): void
289
305
{
290
306
$ this ->model ->setWriter (
291
307
$ this ->objectManager ->create (
@@ -313,8 +329,10 @@ public function testCategoryIdsFilter()
313
329
* Verify that export processed successfully with wrong category path
314
330
*
315
331
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_broken_categories_path.php
332
+ *
333
+ * @return void
316
334
*/
317
- public function testExportWithWrongCategoryPath ()
335
+ public function testExportWithWrongCategoryPath (): void
318
336
{
319
337
$ this ->model ->setWriter (
320
338
$ this ->objectManager ->create (
@@ -329,8 +347,10 @@ public function testExportWithWrongCategoryPath()
329
347
* Test 'hide from product page' export for non-default store.
330
348
*
331
349
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_images.php
350
+ *
351
+ * @return void
332
352
*/
333
- public function testExportWithMedia ()
353
+ public function testExportWithMedia (): void
334
354
{
335
355
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
336
356
$ productRepository = $ this ->objectManager ->get (\Magento \Catalog \Api \ProductRepositoryInterface::class);
@@ -359,6 +379,7 @@ public function testExportWithMedia()
359
379
360
380
/**
361
381
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php
382
+ *
362
383
* @return void
363
384
*/
364
385
public function testExportWithCustomOptions (): void
@@ -403,12 +424,19 @@ public function testExportWithCustomOptions(): void
403
424
/** @var \Magento\Framework\File\Csv $csv */
404
425
$ csv = $ this ->objectManager ->get (\Magento \Framework \File \Csv::class);
405
426
$ data = $ csv ->getData ($ varDirectory ->getAbsolutePath ('test_product_with_custom_options_and_second_store.csv ' ));
427
+ $ keys = array_shift ($ data );
428
+ $ products = [];
429
+ foreach ($ data as $ productData ) {
430
+ $ products [] = array_combine ($ keys , $ productData );
431
+ }
432
+ $ products = array_filter ($ products , function (array $ product ) {
433
+ return $ product ['sku ' ] === 'simple ' ;
434
+ });
406
435
$ customOptionData = [];
407
- foreach ($ data [0 ] as $ columnNumber => $ columnName ) {
408
- if ($ columnName === 'custom_options ' ) {
409
- $ customOptionData ['admin_store ' ] = $ this ->parseExportedCustomOption ($ data [1 ][$ columnNumber ]);
410
- $ customOptionData [$ storeCode ] = $ this ->parseExportedCustomOption ($ data [2 ][$ columnNumber ]);
411
- }
436
+
437
+ foreach ($ products as $ product ) {
438
+ $ storeCode = $ product ['store_view_code ' ] ?: 'admin_store ' ;
439
+ $ customOptionData [$ storeCode ] = $ this ->parseExportedCustomOption ($ product ['custom_options ' ]);
412
440
}
413
441
414
442
self ::assertSame ($ expectedData , $ customOptionData );
@@ -418,8 +446,10 @@ public function testExportWithCustomOptions(): void
418
446
* Check that no duplicate entities when multiple custom options used
419
447
*
420
448
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_options.php
449
+ *
450
+ * @return void
421
451
*/
422
- public function testExportWithMultipleOptions ()
452
+ public function testExportWithMultipleOptions (): void
423
453
{
424
454
$ expectedCount = 1 ;
425
455
$ resultsFilename = 'export_results.csv ' ;
@@ -442,6 +472,8 @@ public function testExportWithMultipleOptions()
442
472
}
443
473
444
474
/**
475
+ * Parse exported custom options
476
+ *
445
477
* @param string $exportedCustomOption
446
478
* @return array
447
479
*/
@@ -476,8 +508,10 @@ function ($input) {
476
508
* @magentoConfigFixture current_store catalog/price/scope 1
477
509
* @magentoDbIsolation disabled
478
510
* @magentoAppArea adminhtml
511
+ *
512
+ * @return void
479
513
*/
480
- public function testExportProductWithTwoWebsites ()
514
+ public function testExportProductWithTwoWebsites (): void
481
515
{
482
516
$ globalStoreCode = 'admin ' ;
483
517
$ secondStoreCode = 'fixture_second_store ' ;
@@ -539,17 +573,19 @@ public function testExportProductWithTwoWebsites()
539
573
/**
540
574
* Verify that "stock status" filter correctly applies to export result
541
575
*
576
+ * @magentoDataFixture Magento/Catalog/_files/multiple_products_with_few_out_of_stock.php
577
+ * @dataProvider filterByQuantityAndStockStatusDataProvider
578
+ *
542
579
* @param string $value
543
580
* @param array $productsIncluded
544
581
* @param array $productsNotIncluded
545
- * @magentoDataFixture Magento/Catalog/_files/multiple_products_with_few_out_of_stock.php
546
- * @dataProvider filterByQuantityAndStockStatusDataProvider
582
+ * @return void
547
583
*/
548
584
public function testFilterByQuantityAndStockStatus (
549
585
string $ value ,
550
586
array $ productsIncluded ,
551
587
array $ productsNotIncluded
552
- ) {
588
+ ): void {
553
589
$ exportData = $ this ->doExport (['quantity_and_stock_status ' => $ value ]);
554
590
foreach ($ productsIncluded as $ productName ) {
555
591
$ this ->assertContains ($ productName , $ exportData );
@@ -569,35 +605,37 @@ public function filterByQuantityAndStockStatusDataProvider(): array
569
605
[
570
606
'Simple Product OOS ' ,
571
607
'Simple Product Not Visible ' ,
572
- 'Simple Product Visible and InStock '
608
+ 'Simple Product Visible and InStock ' ,
573
609
],
574
610
[
575
- ]
611
+ ],
576
612
],
577
613
[
578
614
'1 ' ,
579
615
[
580
616
'Simple Product Not Visible ' ,
581
- 'Simple Product Visible and InStock '
617
+ 'Simple Product Visible and InStock ' ,
582
618
],
583
619
[
584
- 'Simple Product OOS '
585
- ]
620
+ 'Simple Product OOS ' ,
621
+ ],
586
622
],
587
623
[
588
624
'0 ' ,
589
625
[
590
- 'Simple Product OOS '
626
+ 'Simple Product OOS ' ,
591
627
],
592
628
[
593
629
'Simple Product Not Visible ' ,
594
- 'Simple Product Visible and InStock '
595
- ]
596
- ]
630
+ 'Simple Product Visible and InStock ' ,
631
+ ],
632
+ ],
597
633
];
598
634
}
599
635
600
636
/**
637
+ * Perform export
638
+ *
601
639
* @param array $filters
602
640
* @return string
603
641
*/
0 commit comments