From 2134e310678c9cbcd86063b4fc322c433745bd61 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 24 May 2014 21:16:53 +1200 Subject: [PATCH] CRM-14743 additional test --- tests/phpunit/api/v3/ContactTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 673d831a7f..0fc15677c4 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -1821,4 +1821,25 @@ class api_v3_ContactTest extends CiviUnitTestCase { $contacts = $this->callAPISuccess('contact', 'get', array('modified_date' => array('>' => '2014-01-01'))); $this->assertEquals($contacts['count'], $preExistingContactCount); } + + /** + /** + * CRM-14743 - test api respects search operators + */ + function testGetCreatedDateByOperators() { + $preExistingContactCount = CRM_Core_DAO::singleValueQuery('select count(*) FROM civicrm_contact'); + $contact1 = $this->individualCreate(); + $sql = "UPDATE civicrm_contact SET created_date = '2012-01-01' WHERE id = " . $contact1; + CRM_Core_DAO::executeQuery($sql); + $contact2 = $this->individualCreate(); + $sql = "UPDATE civicrm_contact SET created_date = '2012-02-01' WHERE id = " . $contact2; + CRM_Core_DAO::executeQuery($sql); + $contact3 = $this->householdCreate(); + $sql = "UPDATE civicrm_contact SET created_date = '2012-03-01' WHERE id = " . $contact3; + CRM_Core_DAO::executeQuery($sql); + $contacts = $this->callAPISuccess('contact', 'get', array('created_date' => array('<' => '2014-01-01'))); + $this->assertEquals($contacts['count'], 3); + $contacts = $this->callAPISuccess('contact', 'get', array('created_date' => array('>' => '2014-01-01'))); + $this->assertEquals($contacts['count'], $preExistingContactCount); + } } -- 2.25.1