CRM-14446 contact api.getfields declare birth_date & deceased_date high low filters...
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 9 Apr 2014 05:22:43 +0000 (17:22 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Wed, 9 Apr 2014 05:22:43 +0000 (17:22 +1200)
----------------------------------------
* CRM-14446:
  https://issues.civicrm.org/jira/browse/CRM-14446

api/v3/Contact.php
tests/phpunit/api/v3/ContactTest.php

index 15bd0899581f4c140101f71fdf1f7a4831a0cbf8..1efb42a13da38ff03c96391970897d3642417255 100644 (file)
@@ -201,6 +201,10 @@ function _civicrm_api3_contact_get_spec(&$params) {
   $params['group_id']['title'] = 'Group Memberships (filter)';
   $params['group']['title'] = 'Group Memberships (filter, array)';
   $params['tag']['title'] = 'Assigned tags (filter, array)';
+  $params['birth_date_low'] = array('name' => 'birth_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birthdate is equal to or greater than'));
+  $params['birth_date_high'] = array('name' => 'birth_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birthdate is equal to or less than'));
+  $params['deceased_date_low'] = array('name' => 'deceased_date_low','type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or greater than'));
+  $params['deceased_date_high'] = array('name' => 'deceased_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or less than'));
 }
 
 /**
index e7ca3fd241df3954f70d7d4116b36542fe0c816b..88d40f1aa69470070c7adf9ae747b3a77ef42ca3 100644 (file)
@@ -1229,6 +1229,9 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('contact', 'get', array('birth_date_low' => date('Y-m-d', strtotime('-6 years')), 'birth_date_high' => date('Y-m-d', strtotime('- 3 years'))));
     $this->assertEquals(1, $result['count']);
     $this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['birth_date']);
+    $result = $this->callAPISuccess('contact', 'get', array('birth_date_low' => '-6 years', 'birth_date_high' => '- 3 years'));
+    $this->assertEquals(1, $result['count']);
+    $this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['birth_date']);
   }
 
   /**
@@ -1249,7 +1252,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('contact', 'get', array('deceased_date_high' => date('Y-m-d', strtotime('-6 years'))));
     $this->assertEquals(1, $result['count']);
     $this->assertEquals(date('Y-m-d', strtotime('first day of next month -20 years')), $result['values'][$contact3['id']]['deceased_date']);
-    $result = $this->callAPISuccess('contact', 'get', array('deceased_date_low' => date('Y-m-d', strtotime('-6 years')), 'deceased_date_high' => date('Y-m-d', strtotime('- 3 years'))));
+    $result = $this->callAPISuccess('contact', 'get', array('deceased_date_low' => '-6 years', 'deceased_date_high' => date('Y-m-d', strtotime('- 3 years'))));
     $this->assertEquals(1, $result['count']);
     $this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['deceased_date']);
   }