|
14 | 14 | use Magento\Catalog\Model\Product;
|
15 | 15 | use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
|
16 | 16 | use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
|
17 |
| -use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface; |
18 | 17 | use Magento\CatalogInventory\Model\Stock;
|
19 | 18 | use Magento\CatalogInventory\Model\StockRegistry;
|
20 | 19 | use Magento\CatalogInventory\Model\StockRegistryStorage;
|
@@ -57,21 +56,6 @@ class ProductTest extends \Magento\TestFramework\Indexer\TestCase
|
57 | 56 | */
|
58 | 57 | protected $_model;
|
59 | 58 |
|
60 |
| - /** |
61 |
| - * @var \Magento\CatalogImportExport\Model\Import\Uploader |
62 |
| - */ |
63 |
| - protected $_uploader; |
64 |
| - |
65 |
| - /** |
66 |
| - * @var \Magento\CatalogImportExport\Model\Import\UploaderFactory |
67 |
| - */ |
68 |
| - protected $_uploaderFactory; |
69 |
| - |
70 |
| - /** |
71 |
| - * @var \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface|\PHPUnit\Framework\MockObject\MockObject |
72 |
| - */ |
73 |
| - protected $_stockStateProvider; |
74 |
| - |
75 | 59 | /**
|
76 | 60 | * @var \Magento\Framework\ObjectManagerInterface
|
77 | 61 | */
|
@@ -1230,38 +1214,6 @@ public function testInvalidSkuLink()
|
1230 | 1214 | $this->assertArrayNotHasKey("simple2", $products, "Simple Product2 should not have been imported");
|
1231 | 1215 | }
|
1232 | 1216 |
|
1233 |
| - /** |
1234 |
| - * @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute.php |
1235 |
| - * @magentoAppIsolation enabled |
1236 |
| - * @magentoDbIsolation enabled |
1237 |
| - */ |
1238 |
| - public function testValidateInvalidMultiselectValues() |
1239 |
| - { |
1240 |
| - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( |
1241 |
| - \Magento\Framework\Filesystem::class |
1242 |
| - ); |
1243 |
| - $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); |
1244 |
| - $source = $this->objectManager->create( |
1245 |
| - \Magento\ImportExport\Model\Import\Source\Csv::class, |
1246 |
| - [ |
1247 |
| - 'file' => __DIR__ . '/_files/products_with_invalid_multiselect_values.csv', |
1248 |
| - 'directory' => $directory |
1249 |
| - ] |
1250 |
| - ); |
1251 |
| - $errors = $this->_model->setParameters( |
1252 |
| - ['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'] |
1253 |
| - )->setSource( |
1254 |
| - $source |
1255 |
| - )->validateData(); |
1256 |
| - |
1257 |
| - $this->assertTrue($errors->getErrorsCount() == 1); |
1258 |
| - $this->assertEquals( |
1259 |
| - "Value for 'multiselect_attribute' attribute contains incorrect value, " |
1260 |
| - . "see acceptable values on settings specified for Admin", |
1261 |
| - $errors->getErrorByRowNumber(1)[0]->getErrorMessage() |
1262 |
| - ); |
1263 |
| - } |
1264 |
| - |
1265 | 1217 | /**
|
1266 | 1218 | * @magentoDataFixture Magento/Catalog/_files/categories.php
|
1267 | 1219 | * @magentoDataFixture Magento/Store/_files/website.php
|
@@ -1598,97 +1550,6 @@ protected function loadCategoryByName($categoryName)
|
1598 | 1550 | return $collection->getItemByColumnValue('name', $categoryName);
|
1599 | 1551 | }
|
1600 | 1552 |
|
1601 |
| - /** |
1602 |
| - * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php |
1603 |
| - * @magentoAppIsolation enabled |
1604 |
| - * @dataProvider validateUrlKeysDataProvider |
1605 |
| - * @param $importFile string |
1606 |
| - * @param $expectedErrors array |
1607 |
| - * @throws \Magento\Framework\Exception\LocalizedException |
1608 |
| - */ |
1609 |
| - public function testValidateUrlKeys($importFile, $expectedErrors) |
1610 |
| - { |
1611 |
| - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( |
1612 |
| - \Magento\Framework\Filesystem::class |
1613 |
| - ); |
1614 |
| - $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); |
1615 |
| - |
1616 |
| - $source = $this->objectManager->create( |
1617 |
| - \Magento\ImportExport\Model\Import\Source\Csv::class, |
1618 |
| - [ |
1619 |
| - 'file' => __DIR__ . '/_files/' . $importFile, |
1620 |
| - 'directory' => $directory |
1621 |
| - ] |
1622 |
| - ); |
1623 |
| - /** @var \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface $errors */ |
1624 |
| - $errors = $this->_model->setParameters( |
1625 |
| - ['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'] |
1626 |
| - )->setSource( |
1627 |
| - $source |
1628 |
| - )->validateData(); |
1629 |
| - $this->assertEquals( |
1630 |
| - $expectedErrors[RowValidatorInterface::ERROR_DUPLICATE_URL_KEY], |
1631 |
| - count($errors->getErrorsByCode([RowValidatorInterface::ERROR_DUPLICATE_URL_KEY])) |
1632 |
| - ); |
1633 |
| - } |
1634 |
| - |
1635 |
| - /** |
1636 |
| - * @return array |
1637 |
| - */ |
1638 |
| - public function validateUrlKeysDataProvider() |
1639 |
| - { |
1640 |
| - return [ |
1641 |
| - [ |
1642 |
| - 'products_to_check_valid_url_keys.csv', |
1643 |
| - [ |
1644 |
| - RowValidatorInterface::ERROR_DUPLICATE_URL_KEY => 0 |
1645 |
| - ] |
1646 |
| - ], |
1647 |
| - [ |
1648 |
| - 'products_to_check_duplicated_url_keys.csv', |
1649 |
| - [ |
1650 |
| - RowValidatorInterface::ERROR_DUPLICATE_URL_KEY => 2 |
1651 |
| - ] |
1652 |
| - ], |
1653 |
| - [ |
1654 |
| - 'products_to_check_duplicated_names.csv' , |
1655 |
| - [ |
1656 |
| - RowValidatorInterface::ERROR_DUPLICATE_URL_KEY => 1 |
1657 |
| - ] |
1658 |
| - ] |
1659 |
| - ]; |
1660 |
| - } |
1661 |
| - |
1662 |
| - /** |
1663 |
| - * @magentoDataFixture Magento/Store/_files/website.php |
1664 |
| - * @magentoDataFixture Magento/Store/_files/core_fixturestore.php |
1665 |
| - * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php |
1666 |
| - * @magentoAppIsolation enabled |
1667 |
| - * @magentoDbIsolation enabled |
1668 |
| - */ |
1669 |
| - public function testValidateUrlKeysMultipleStores() |
1670 |
| - { |
1671 |
| - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( |
1672 |
| - \Magento\Framework\Filesystem::class |
1673 |
| - ); |
1674 |
| - $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); |
1675 |
| - |
1676 |
| - $source = $this->objectManager->create( |
1677 |
| - \Magento\ImportExport\Model\Import\Source\Csv::class, |
1678 |
| - [ |
1679 |
| - 'file' => __DIR__ . '/_files/products_to_check_valid_url_keys_multiple_stores.csv', |
1680 |
| - 'directory' => $directory |
1681 |
| - ] |
1682 |
| - ); |
1683 |
| - $errors = $this->_model->setParameters( |
1684 |
| - ['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'] |
1685 |
| - )->setSource( |
1686 |
| - $source |
1687 |
| - )->validateData(); |
1688 |
| - |
1689 |
| - $this->assertTrue($errors->getErrorsCount() == 0); |
1690 |
| - } |
1691 |
| - |
1692 | 1553 | /**
|
1693 | 1554 | * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_product_links_data.php
|
1694 | 1555 | * @magentoAppArea adminhtml
|
@@ -2378,149 +2239,6 @@ private function getProductBySku($sku, $store = null)
|
2378 | 2239 | return $product;
|
2379 | 2240 | }
|
2380 | 2241 |
|
2381 |
| - /** |
2382 |
| - * @param array $row |
2383 |
| - * @param string|null $behavior |
2384 |
| - * @param bool $expectedResult |
2385 |
| - * @magentoAppArea adminhtml |
2386 |
| - * @magentoAppIsolation enabled |
2387 |
| - * @magentoDbIsolation enabled |
2388 |
| - * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php |
2389 |
| - * @dataProvider validateRowDataProvider |
2390 |
| - */ |
2391 |
| - public function testValidateRow(array $row, $behavior, $expectedResult) |
2392 |
| - { |
2393 |
| - $this->_model->setParameters(['behavior' => $behavior, 'entity' => 'catalog_product']); |
2394 |
| - $this->assertSame($expectedResult, $this->_model->validateRow($row, 1)); |
2395 |
| - } |
2396 |
| - |
2397 |
| - /** |
2398 |
| - * @return array |
2399 |
| - */ |
2400 |
| - public function validateRowDataProvider() |
2401 |
| - { |
2402 |
| - return [ |
2403 |
| - [ |
2404 |
| - 'row' => ['sku' => 'simple products'], |
2405 |
| - 'behavior' => null, |
2406 |
| - 'expectedResult' => true, |
2407 |
| - ], |
2408 |
| - [ |
2409 |
| - 'row' => ['sku' => 'simple products absent'], |
2410 |
| - 'behavior' => null, |
2411 |
| - 'expectedResult' => false, |
2412 |
| - ], |
2413 |
| - [ |
2414 |
| - 'row' => [ |
2415 |
| - 'sku' => 'simple products absent', |
2416 |
| - 'name' => 'Test', |
2417 |
| - 'product_type' => 'simple', |
2418 |
| - '_attribute_set' => 'Default', |
2419 |
| - 'price' => 10.20, |
2420 |
| - ], |
2421 |
| - 'behavior' => null, |
2422 |
| - 'expectedResult' => true, |
2423 |
| - ], |
2424 |
| - [ |
2425 |
| - 'row' => ['sku' => 'simple products'], |
2426 |
| - 'behavior' => Import::BEHAVIOR_ADD_UPDATE, |
2427 |
| - 'expectedResult' => true, |
2428 |
| - ], |
2429 |
| - [ |
2430 |
| - 'row' => ['sku' => 'simple products absent'], |
2431 |
| - 'behavior' => Import::BEHAVIOR_ADD_UPDATE, |
2432 |
| - 'expectedResult' => false, |
2433 |
| - ], |
2434 |
| - [ |
2435 |
| - 'row' => [ |
2436 |
| - 'sku' => 'simple products absent', |
2437 |
| - 'name' => 'Test', |
2438 |
| - 'product_type' => 'simple', |
2439 |
| - '_attribute_set' => 'Default', |
2440 |
| - 'price' => 10.20, |
2441 |
| - ], |
2442 |
| - 'behavior' => Import::BEHAVIOR_ADD_UPDATE, |
2443 |
| - 'expectedResult' => true, |
2444 |
| - ], |
2445 |
| - [ |
2446 |
| - 'row' => ['sku' => 'simple products'], |
2447 |
| - 'behavior' => Import::BEHAVIOR_DELETE, |
2448 |
| - 'expectedResult' => true, |
2449 |
| - ], |
2450 |
| - [ |
2451 |
| - 'row' => ['sku' => 'simple products absent'], |
2452 |
| - 'behavior' => Import::BEHAVIOR_DELETE, |
2453 |
| - 'expectedResult' => false, |
2454 |
| - ], |
2455 |
| - [ |
2456 |
| - 'row' => ['sku' => 'simple products'], |
2457 |
| - 'behavior' => Import::BEHAVIOR_REPLACE, |
2458 |
| - 'expectedResult' => false, |
2459 |
| - ], |
2460 |
| - [ |
2461 |
| - 'row' => ['sku' => 'simple products absent'], |
2462 |
| - 'behavior' => Import::BEHAVIOR_REPLACE, |
2463 |
| - 'expectedResult' => false, |
2464 |
| - ], |
2465 |
| - [ |
2466 |
| - 'row' => [ |
2467 |
| - 'sku' => 'simple products absent', |
2468 |
| - 'name' => 'Test', |
2469 |
| - 'product_type' => 'simple', |
2470 |
| - '_attribute_set' => 'Default', |
2471 |
| - 'price' => 10.20, |
2472 |
| - ], |
2473 |
| - 'behavior' => Import::BEHAVIOR_REPLACE, |
2474 |
| - 'expectedResult' => false, |
2475 |
| - ], |
2476 |
| - [ |
2477 |
| - 'row' => [ |
2478 |
| - 'sku' => 'simple products', |
2479 |
| - 'name' => 'Test', |
2480 |
| - 'product_type' => 'simple', |
2481 |
| - '_attribute_set' => 'Default', |
2482 |
| - 'price' => 10.20, |
2483 |
| - ], |
2484 |
| - 'behavior' => Import::BEHAVIOR_REPLACE, |
2485 |
| - 'expectedResult' => true, |
2486 |
| - ], |
2487 |
| - [ |
2488 |
| - 'row' => ['sku' => 'sku with whitespace ', |
2489 |
| - 'name' => 'Test', |
2490 |
| - 'product_type' => 'simple', |
2491 |
| - '_attribute_set' => 'Default', |
2492 |
| - 'price' => 10.20, |
2493 |
| - ], |
2494 |
| - 'behavior' => Import::BEHAVIOR_ADD_UPDATE, |
2495 |
| - 'expectedResult' => false, |
2496 |
| - ], |
2497 |
| - ]; |
2498 |
| - } |
2499 |
| - |
2500 |
| - /** |
2501 |
| - * @covers \Magento\ImportExport\Model\Import\Entity\AbstractEntity::_saveValidatedBunches |
2502 |
| - */ |
2503 |
| - public function testValidateData() |
2504 |
| - { |
2505 |
| - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() |
2506 |
| - ->create(\Magento\Framework\Filesystem::class); |
2507 |
| - $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); |
2508 |
| - |
2509 |
| - $source = $this->objectManager->create( |
2510 |
| - \Magento\ImportExport\Model\Import\Source\Csv::class, |
2511 |
| - [ |
2512 |
| - 'file' => __DIR__ . '/_files/products_to_import.csv', |
2513 |
| - 'directory' => $directory |
2514 |
| - ] |
2515 |
| - ); |
2516 |
| - |
2517 |
| - $errors = $this->_model->setParameters( |
2518 |
| - ['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'] |
2519 |
| - )->setSource($source)->validateData(); |
2520 |
| - |
2521 |
| - $this->assertTrue($errors->getErrorsCount() == 0); |
2522 |
| - } |
2523 |
| - |
2524 | 2242 | /**
|
2525 | 2243 | * Tests situation when images for importing products are already present in filesystem.
|
2526 | 2244 | *
|
|
0 commit comments