From: Johan Vervloet Date: Thu, 27 Aug 2015 19:31:44 +0000 (+0200) Subject: CRM-17101 - unit test searching on custom fields with <=. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4347617d93d847cb25e87923c435d5f15b94367d;p=civicrm-core.git CRM-17101 - unit test searching on custom fields with <=. ---------------------------------------- * CRM-17101: civicrm_api3_basic_get does not work for SQL operators on custom fields. https://issues.civicrm.org/jira/browse/CRM-17101 --- diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 10ca656271..1149b8e596 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -449,6 +449,37 @@ class api_v3_EventTest extends CiviUnitTestCase { )); } + /** + * Test searching on custom fields with less than or equal. + * + * See CRM-17101. + */ + public function testEventGetCustomFieldLte() { + // create custom group with custom field on event + $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); + + // Create an event, with a custom value. + $params = $this->_params; + $params['title'] = "My test event."; + $params['start_date'] = "2015-03-14"; + // Just assume that an event type 1 exists. + $params['event_type_id'] = 1; + $params['custom_' . $ids['custom_field_id']] = "AAAA"; + + $save_result = $this->callApiSuccess($this->_entity, 'create', $params); + + // Retrieve the activity, search for custom field < 'BBBB' + $get_result = $this->callAPISuccess($this->_entity, 'get', array( + 'return.custom_' . $ids['custom_field_id'] => 1, + 'custom_' . $ids['custom_field_id'] => array('<=' => 'BBBB'), + )); + + // Expect that we find the saved event. + $this->assertArrayKeyExists($save_result['id'], $get_result['values']); + + $this->callAPISuccess($this->_entity, 'Delete', array('id' => $save_result['id'])); + } + /** * Test searching on custom fields with netsted call with id param. *