From ffe87781139523bc614bedfc5f8561ce543fd495 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Fri, 25 Sep 2015 00:17:48 +1200 Subject: [PATCH] CRM-17275 Contact.duplicate api test --- .../CRM/Contact/Import/Parser/ContactTest.php | 1 + tests/phpunit/api/v3/ContactTest.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index ffb85d4860..8138ad988d 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -131,4 +131,5 @@ class CRM_Contact_Imports_Parser_ContactTest extends CiviUnitTestCase { $parser->init(); $this->assertEquals($expectedResult, $parser->import($onDuplicateAction, $values)); } + } diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 6342641d1f..c531525baf 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -2708,4 +2708,35 @@ class api_v3_ContactTest extends CiviUnitTestCase { } } + /** + * Test the duplicate check function. + */ + public function testDuplicateCheck() { + $this->callAPISuccess('Contact', 'create', array( + 'first_name' => 'Harry', + 'last_name' => 'Potter', + 'email' => 'harry@hogwarts.edu', + 'contact_type' => 'Individual', + )); + $result = $this->callAPISuccess('Contact', 'duplicatecheck', array( + 'match' => array( + 'first_name' => 'Harry', + 'last_name' => 'Potter', + 'email' => 'harry@hogwarts.edu', + 'contact_type' => 'Individual', + ), + )); + + $this->assertEquals(1, $result['count']); + $result = $this->callAPISuccess('Contact', 'duplicatecheck', array( + 'match' => array( + 'first_name' => 'Harry', + 'last_name' => 'Potter', + 'email' => 'no5@privet.drive', + 'contact_type' => 'Individual', + ), + )); + $this->assertEquals(0, $result['count']); + } + } -- 2.25.1