Closed mmenozzi closed 1 year ago
Errors are in the Product Importer integration tests because now we validate the product and we do not allow to have product with invalid state:
There were 3 errors:
1) Tests\Webgriffe\SyliusAkeneoPlugin\Integration\Product\ImporterTest::it_does_not_fail_with_empty_translations
Webgriffe\SyliusAkeneoPlugin\ProductValidationException: Object(Sylius\Component\Core\Model\ProductVariant).channelPricings:
You must define price for every channel.
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/src/ProductValidator.php:30
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/src/Product/Importer.php:101
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/tests/Integration/Product/ImporterTest.php:689
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/vendor/bin/phpunit:127
2) Tests\Webgriffe\SyliusAkeneoPlugin\Integration\Product\ImporterTest::it_disable_old_product_while_importing_product_variant_from_configurable_that_was_simple
Webgriffe\SyliusAkeneoPlugin\ProductValidationException: Object(Sylius\Component\Core\Model\Product).images[0].file:
An empty file is not allowed. (code 5d743385-9775-4aa5-8ff5-495fb1e60137)
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/src/ProductValidator.php:30
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/src/Product/Importer.php:101
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/tests/Integration/Product/ImporterTest.php:758
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/vendor/bin/phpunit:1[27](https://github.com/webgriffe/SyliusAkeneoPlugin/actions/runs/6049525869/job/16416973671?pr=169#step:31:28)
3) Tests\Webgriffe\SyliusAkeneoPlugin\Integration\Product\ImporterTest::it_enables_product_without_variants_while_importing_a_new_one
Webgriffe\SyliusAkeneoPlugin\ProductValidationException: Object(Sylius\Component\Core\Model\Product).images[0].file:
An empty file is not allowed. (code 5d743385-9775-4aa5-8ff5-495fb1e60137)
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/src/ProductValidator.php:[30](https://github.com/webgriffe/SyliusAkeneoPlugin/actions/runs/6049525869/job/16416973671?pr=169#step:31:31)
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/src/Product/Importer.php:101
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/tests/Integration/Product/ImporterTest.php:789
/home/runner/work/SyliusAkeneoPlugin/SyliusAkeneoPlugin/vendor/bin/phpunit:127
Fixes: #148 #137 (maybe others) Replaces: #149
Here we validate the product variant and its product before saving them. This way every validation error that would be thrown in the Sylius backend is triggered during the importer before reaching Doctrine to avoid subsequent "EntityManager is closed" errors.