@@ -1431,4 +1431,113 @@ public function testProductWithWrappedAdditionalAttributes()
1431
1431
$ this ->assertEquals (implode (', ' , [$ multiselectOptions [1 ]->getValue (), $ multiselectOptions [2 ]->getValue ()]),
1432
1432
$ product2 ->getData ('multiselect_attribute ' ));
1433
1433
}
1434
+
1435
+ /**
1436
+ * @param array $row
1437
+ * @param string|null $behavior
1438
+ * @param bool $expectedResult
1439
+ * @magentoAppArea adminhtml
1440
+ * @magentoAppIsolation enabled
1441
+ * @magentoDbIsolation enabled
1442
+ * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
1443
+ * @dataProvider validateRowDataProvider
1444
+ */
1445
+ public function testValidateRow (array $ row , $ behavior , $ expectedResult )
1446
+ {
1447
+ $ this ->_model ->setParameters (['behavior ' => $ behavior , 'entity ' => 'catalog_product ' ]);
1448
+ $ this ->assertSame ($ expectedResult , $ this ->_model ->validateRow ($ row , 1 ));
1449
+ }
1450
+
1451
+ /**
1452
+ * @return array
1453
+ */
1454
+ public function validateRowDataProvider ()
1455
+ {
1456
+ return [
1457
+ [
1458
+ 'row ' => ['sku ' => 'simple products ' ],
1459
+ 'behavior ' => null ,
1460
+ 'expectedResult ' => true ,
1461
+ ],
1462
+ [
1463
+ 'row ' => ['sku ' => 'simple products absent ' ],
1464
+ 'behavior ' => null ,
1465
+ 'expectedResult ' => false ,
1466
+ ],
1467
+ [
1468
+ 'row ' => [
1469
+ 'sku ' => 'simple products absent ' ,
1470
+ 'name ' => 'Test ' ,
1471
+ 'product_type ' => 'simple ' ,
1472
+ '_attribute_set ' => 'Default ' ,
1473
+ 'price ' => 10.20 ,
1474
+ ],
1475
+ 'behavior ' => null ,
1476
+ 'expectedResult ' => true ,
1477
+ ],
1478
+ [
1479
+ 'row ' => ['sku ' => 'simple products ' ],
1480
+ 'behavior ' => Import::BEHAVIOR_ADD_UPDATE ,
1481
+ 'expectedResult ' => true ,
1482
+ ],
1483
+ [
1484
+ 'row ' => ['sku ' => 'simple products absent ' ],
1485
+ 'behavior ' => Import::BEHAVIOR_ADD_UPDATE ,
1486
+ 'expectedResult ' => false ,
1487
+ ],
1488
+ [
1489
+ 'row ' => [
1490
+ 'sku ' => 'simple products absent ' ,
1491
+ 'name ' => 'Test ' ,
1492
+ 'product_type ' => 'simple ' ,
1493
+ '_attribute_set ' => 'Default ' ,
1494
+ 'price ' => 10.20 ,
1495
+ ],
1496
+ 'behavior ' => Import::BEHAVIOR_ADD_UPDATE ,
1497
+ 'expectedResult ' => true ,
1498
+ ],
1499
+ [
1500
+ 'row ' => ['sku ' => 'simple products ' ],
1501
+ 'behavior ' => Import::BEHAVIOR_DELETE ,
1502
+ 'expectedResult ' => true ,
1503
+ ],
1504
+ [
1505
+ 'row ' => ['sku ' => 'simple products absent ' ],
1506
+ 'behavior ' => Import::BEHAVIOR_DELETE ,
1507
+ 'expectedResult ' => false ,
1508
+ ],
1509
+ [
1510
+ 'row ' => ['sku ' => 'simple products ' ],
1511
+ 'behavior ' => Import::BEHAVIOR_REPLACE ,
1512
+ 'expectedResult ' => false ,
1513
+ ],
1514
+ [
1515
+ 'row ' => ['sku ' => 'simple products absent ' ],
1516
+ 'behavior ' => Import::BEHAVIOR_REPLACE ,
1517
+ 'expectedResult ' => false ,
1518
+ ],
1519
+ [
1520
+ 'row ' => [
1521
+ 'sku ' => 'simple products absent ' ,
1522
+ 'name ' => 'Test ' ,
1523
+ 'product_type ' => 'simple ' ,
1524
+ '_attribute_set ' => 'Default ' ,
1525
+ 'price ' => 10.20 ,
1526
+ ],
1527
+ 'behavior ' => Import::BEHAVIOR_REPLACE ,
1528
+ 'expectedResult ' => false ,
1529
+ ],
1530
+ [
1531
+ 'row ' => [
1532
+ 'sku ' => 'simple products ' ,
1533
+ 'name ' => 'Test ' ,
1534
+ 'product_type ' => 'simple ' ,
1535
+ '_attribute_set ' => 'Default ' ,
1536
+ 'price ' => 10.20 ,
1537
+ ],
1538
+ 'behavior ' => Import::BEHAVIOR_REPLACE ,
1539
+ 'expectedResult ' => true ,
1540
+ ],
1541
+ ];
1542
+ }
1434
1543
}
0 commit comments