Skip to content

Commit c6b06bf

Browse files
author
cspruiell
committed
MAGETWO-60479: Importing existing products with 'Replace' behavior gives no errors and deletes them
- add tests
1 parent e053303 commit c6b06bf

File tree

1 file changed

+164
-0
lines changed
  • dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import

1 file changed

+164
-0
lines changed

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,4 +1383,168 @@ public function testProductWithWrappedAdditionalAttributes()
13831383
$this->assertEquals(implode(',', [$multiselectOptions[1]->getValue(), $multiselectOptions[2]->getValue()]),
13841384
$product2->getData('multiselect_attribute'));
13851385
}
1386+
1387+
/**
1388+
* @param array $row
1389+
* @param string|null $behavior
1390+
* @param bool $expectedResult
1391+
* @magentoAppArea adminhtml
1392+
* @magentoAppIsolation enabled
1393+
* @magentoDbIsolation enabled
1394+
* @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
1395+
* @dataProvider validateRowDataProvider
1396+
*/
1397+
public function testValidateRow(array $row, $behavior, $expectedResult)
1398+
{
1399+
$this->_model->setParameters(['behavior' => $behavior, 'entity' => 'catalog_product']);
1400+
$this->assertSame($expectedResult, $this->_model->validateRow($row, 1));
1401+
}
1402+
1403+
/**
1404+
* @return array
1405+
*/
1406+
public function validateRowDataProvider()
1407+
{
1408+
return [
1409+
[
1410+
'row' => ['sku' => 'simple products'],
1411+
'behavior' => null,
1412+
'expectedResult' => true,
1413+
],
1414+
[
1415+
'row' => ['sku' => 'simple products absent'],
1416+
'behavior' => null,
1417+
'expectedResult' => false,
1418+
],
1419+
[
1420+
'row' => [
1421+
'sku' => 'simple products absent',
1422+
'name' => 'Test',
1423+
'product_type' => 'simple',
1424+
'_attribute_set' => 'Default',
1425+
'price' => 10.20,
1426+
],
1427+
'behavior' => null,
1428+
'expectedResult' => true,
1429+
],
1430+
[
1431+
'row' => ['sku' => 'simple products'],
1432+
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
1433+
'expectedResult' => true,
1434+
],
1435+
[
1436+
'row' => ['sku' => 'simple products absent'],
1437+
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
1438+
'expectedResult' => false,
1439+
],
1440+
[
1441+
'row' => [
1442+
'sku' => 'simple products absent',
1443+
'name' => 'Test',
1444+
'product_type' => 'simple',
1445+
'_attribute_set' => 'Default',
1446+
'price' => 10.20,
1447+
],
1448+
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
1449+
'expectedResult' => true,
1450+
],
1451+
[
1452+
'row' => ['sku' => 'simple products'],
1453+
'behavior' => Import::BEHAVIOR_DELETE,
1454+
'expectedResult' => true,
1455+
],
1456+
[
1457+
'row' => ['sku' => 'simple products absent'],
1458+
'behavior' => Import::BEHAVIOR_DELETE,
1459+
'expectedResult' => false,
1460+
],
1461+
[
1462+
'row' => ['sku' => 'simple products'],
1463+
'behavior' => Import::BEHAVIOR_REPLACE,
1464+
'expectedResult' => false,
1465+
],
1466+
[
1467+
'row' => ['sku' => 'simple products absent'],
1468+
'behavior' => Import::BEHAVIOR_REPLACE,
1469+
'expectedResult' => false,
1470+
],
1471+
[
1472+
'row' => [
1473+
'sku' => 'simple products absent',
1474+
'name' => 'Test',
1475+
'product_type' => 'simple',
1476+
'_attribute_set' => 'Default',
1477+
'price' => 10.20,
1478+
],
1479+
'behavior' => Import::BEHAVIOR_REPLACE,
1480+
'expectedResult' => false,
1481+
],
1482+
[
1483+
'row' => [
1484+
'sku' => 'simple products',
1485+
'name' => 'Test',
1486+
'product_type' => 'simple',
1487+
'_attribute_set' => 'Default',
1488+
'price' => 10.20,
1489+
],
1490+
'behavior' => Import::BEHAVIOR_REPLACE,
1491+
'expectedResult' => true,
1492+
],
1493+
[
1494+
'row' => [
1495+
'sku' => null,
1496+
'name' => 'Test',
1497+
'product_type' => 'simple',
1498+
'_attribute_set' => 'Default',
1499+
'price' => 10.20,
1500+
],
1501+
'behavior' => Import::BEHAVIOR_REPLACE,
1502+
'expectedResult' => false,
1503+
],
1504+
[
1505+
'row' => [
1506+
'sku' => 'simple products',
1507+
'name' => null,
1508+
'product_type' => 'simple',
1509+
'_attribute_set' => 'Default',
1510+
'price' => 10.20,
1511+
],
1512+
'behavior' => Import::BEHAVIOR_REPLACE,
1513+
'expectedResult' => false,
1514+
],
1515+
[
1516+
'row' => [
1517+
'sku' => 'simple products',
1518+
'name' => 'Test',
1519+
'product_type' => null,
1520+
'_attribute_set' => 'Default',
1521+
'price' => 10.20,
1522+
],
1523+
'behavior' => Import::BEHAVIOR_REPLACE,
1524+
'expectedResult' => false,
1525+
],
1526+
[
1527+
'row' => [
1528+
'sku' => 'simple products',
1529+
'name' => 'Test',
1530+
'product_type' => 'simple',
1531+
'_attribute_set' => null,
1532+
'price' => 10.20,
1533+
],
1534+
'behavior' => Import::BEHAVIOR_REPLACE,
1535+
'expectedResult' => false,
1536+
],
1537+
[
1538+
'row' => [
1539+
'sku' => 'simple products',
1540+
'name' => 'Test',
1541+
'product_type' => 'simple',
1542+
'_attribute_set' => 'Default',
1543+
'price' => null,
1544+
],
1545+
'behavior' => Import::BEHAVIOR_REPLACE,
1546+
'expectedResult' => false,
1547+
],
1548+
];
1549+
}
13861550
}

0 commit comments

Comments
 (0)