Righto, so the tests are passing. And here are the manual tests that I did. It would be good to re-test all of this during QA - along with anything else that I haven't thought of. These tests could also be a good starting point for any further unit/web tests Eileen McNaughton ?
- Merge screen JS displays matching locations on the 'main' contact when 'location' and/or 'type' is changed (all location block entities)
- For each location entity test: overwrite existing, add new, and both of those from different 'original' locations. eg:
- * home address OVER home address
- * work address OVER home address
- * home phone OVER home phone
- * home phone ADD NEW home phone
- * home phone OVR other mobile
- * home phone NEW other fax
- * etc.
- Check safe merge works and catches exceptions
- Check force merge works
The current logic for force merge (before the PR and maintained in the PR) is that all location fields are added, not overwritten. And any conflicts in core details (or the address) are ignored. The details in the 'main' contact supersede those of the 'other' in all cases.
For example:
Other (dupe):
Name: Cat Man
Job title: Villain
Home address: Kittentown
Home phone: cat-123
Work phone: litter-321
Main:
Name: Bat Man
Job title: Hero
Home address: Gotham
Home phone: 123-bat
Work phone: 321-bat
Force merge result:
Name: Bat Man
Job title: Hero
Home address: Gotham
Home phone: 123-bat
Home phone: cat-123
Work phone: 321-bat
Work phone: litter-321
It might be better to force merge based on which contact was most recently updated - and then allow overwriting of matching phones/emails. This would be potentially more destructive, but less messy. It might also result in better information in the core details (ie: the job title from the most recently updated contact would persist). This is something to consider in a future/follow-up issue.
John K. as I tried to fix those tests, am really confused on what scenario you would expect $migrationInfo array holds location parameters under 'location' key BUT as per your earlier changes you have changed the key to 'location_blocks' from 'location' as in https://github.com/civicrm/civicrm-core/pull/7220/files#diff-874dc48dd188118ab0ba9cb9bbde9a02R1260 and in other places. Reason why the tests are throwing notice error : undefined key 'location'.
Does this $migrationInfo can hold location information under both 'location' and 'location_blocks' keys or in other words does these two keys holds separate meaning ? Am pretty sure that this two tests
CRM_Dedupe_MergerTest.testBatchMergeSelectedDuplicates
CRM_Dedupe_MergerTest.testBatchMergeAllDuplicates
are failing afterrefactoring changes done in https://github.com/civicrm/civicrm-core/pull/7220