From: Dave Jenkins Date: Thu, 13 Oct 2016 14:01:46 +0000 (+0100) Subject: CRM-19148 - added test testBatchMergeEmailOnHold. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=861bd03001e175b9b65cbc421731bfd8ad624afa;p=civicrm-core.git CRM-19148 - added test testBatchMergeEmailOnHold. --- diff --git a/tests/phpunit/api/v3/JobTest.php b/tests/phpunit/api/v3/JobTest.php index a77b668e53..d916b57d09 100644 --- a/tests/phpunit/api/v3/JobTest.php +++ b/tests/phpunit/api/v3/JobTest.php @@ -726,6 +726,50 @@ class api_v3_JobTest extends CiviUnitTestCase { ), 4); } + /** + * Test the batch merge respects email "on hold". + * + * Test CRM-19148, Batch merge - Email on hold data lost when there is a conflict. + * + * @dataProvider getOnHoldSets + * + * @param + */ + public function testBatchMergeEmailOnHold($onHold1, $onHold2, $merge) { + $contactID1 = $this->individualCreate(array( + 'api.email.create' => array( + 'email' => 'batman@gotham.met', + 'location_type_id' => 'Work', + 'is_primary' => 1, + 'on_hold' => $onHold1, + ), + )); + $contactID2 = $this->individualCreate(array( + 'api.email.create' => array( + 'email' => 'batman@gotham.met', + 'location_type_id' => 'Work', + 'is_primary' => 1, + 'on_hold' => $onHold2, + ), + )); + $result = $this->callAPISuccess('Job', 'process_batch_merge', array()); + $this->assertEquals($merge, count($result['values']['merged'])); + } + + /** + * Data provider for testBatchMergeEmailOnHold: combinations of on_hold & expected outcomes. + */ + public function getOnHoldSets() { + // Each row specifies: contact 1 on_hold, contact 2 on_hold, merge? (0 or 1), + $sets = array( + array(0, 0, 1), + array(0, 1, 0), + array(1, 0, 0), + array(1, 1, 1), + ); + return $sets; + } + /** * Test the batch merge does not fatal on an empty rule. *