Closed (fixed)
Project:
Commerce Migrate
Version:
8.x-2.x-dev
Component:
Drupal Commerce 1.x
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Aug 2017 at 13:39 UTC
Updated:
29 Aug 2017 at 15:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
heddnComment #4
heddnI think we need to make
d7_productdependent ond7_product_displayand use themigration_lookupplugin to find theproduct_id. When we do that, we also need to make sure installations have at least drupal core 8.3.2 installed. See https://www.drupal.org/node/2861226. And in general, I think we need to start usingmigration_lookupmore often.Comment #5
quietone commentedWhy don't we have a product and a product variation migration? The destination on the product migration is
plugin: 'entity:commerce_product_variation'. Or is there some magic in the commerce code that will also save a product when adding a variation?Comment #6
quietone commentedOh heck, I got mixed up because of the migration names. I tend to expect the name to reflect the destination entity. I'd rather see d7_product_display.yml named d7_product.yml and d7_product_display_type.yml named to d7_product_type.yml. Oh and d7_product_type.yml --> d7_product_variation_type.yml and d7_line_item.yml --> d7_order_item.yml.
But d7_product_display depends on d7_product.
Comment #7
heddnI've added a comment in #2897112: Rename commerce migration yml files. After it lands, I think we need to add a dependency on 8.3.2 and use the migrate_lookup a lot more. We cannot migrate variations and products in a single migration, but we should be able to reference the other migration using the lookup.
Comment #8
quietone commentedI've been looking at this again and using the data provider pattern presents problems. The first is that, as it is currently used in the patch, setup is being run for each input. So, for the ProductVariationTest setup is run 7 times and one product is tested each time. Instead, we should be running setup one and then test the migration of the 7 product variations.
Still, it is attractive to have all the source data in an array. So, I reworked the dataprovider array to pass all the product variations in one large array and then the test was a foreach to test each one. This works just fine. Then I made an error in the source array and ran the test again. The error was change a uid from 0 to 1. The line number where the error occurred is given is the assertProductVariation line, which doesn't help us know on which variation the error occured. Whereas, having a separate assertProductVariation for each entity will let us know which particular product variation is failing.
Because of that I reworked the patch to have the data as an array before each assertion. It is easier to read.
I also modified the ProductTest to execute assertProductEntity before using the product in the loop to test the variation. At least, to me, it seems logical to test the product is correct before using it.
Comment #10
quietone commentedSetting to NR for feedback on comments in #8
Comment #11
heddnI think data providers can provide all the data in a single pass. So we only run the tests a single time, instead of 7. Not sure if that makes things less readable though.
I'll go with either. But we do have a failed test so back to NW.
Comment #12
quietone commented@heddn, In the second paragraph of #8, I did just that. Using the data provider I passed all the data in one array and tested in a foreach loop.
The problem now is that when an error occurs you don't know on which item the error occured. I don't want to add code that makes testing more difficult.
Comment #13
quietone commentedFirst, a reroll.
Comment #15
quietone commentedAnother reroll was needed and now an interdiff fails.
The changes are:
ProductTest - change the product id from 1 to 15 and to setup an array of product information before using assertProduct.
ProductVariationTest - change the product ids to be NULL.
Comment #17
quietone commentedIgnore patch in #15, I uploaded the wrong one.
Comment #18
heddnShould this move to our test trait class?
I'd like to see a test that the product id on the variation matches the product id on the product. It would catch what we found in #2894733-13: Convert Commerce Product and ProfileBilling tests to use CommerceMigrateTestTrait and #2899153: Cannot add variation to cart, due to failed store detection.
Comment #19
heddnComment #20
quietone commented1. Moved
2. Testing for the product id on the product variations is already in the outer for loop, in assertProductVariationEntity.
Comment #22
heddnBetter test coverage now.
Comment #23
heddn