From: Johan Vervloet Date: Mon, 3 Aug 2015 12:02:46 +0000 (+0200) Subject: CRM-16036 - extra unit test. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3dc81e0d3c5162988d921bd4cfbe8e20a2477161;p=civicrm-core.git CRM-16036 - extra unit test. ---------------------------------------- * CRM-16036: API: searching on custom fields does not work https://issues.civicrm.org/jira/browse/CRM-16036 --- diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 0471c10629..598767d0ed 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -449,6 +449,48 @@ class api_v3_EventTest extends CiviUnitTestCase { )); } + /** + * Test searching on custom fields with netsted call with id param. + * + * Search for an event on a custom field, and perform a chained call + * to retrieve it's (non-existing) loc block, using $value-substitution. + * This test just checks whether the event is found, because something + * happened in CiviCRM 4.6.5 that broke my fix for CRM-16036, causing + * CiviCRM to return 0 results. + * Of course, CRM-16168 should also be fixed for this test to pass. + */ + public function testEventSearchCustomFieldWithChainedCall() { + // Create a custom group, and add a custom contact reference field. + $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); + $custom_field_id = $ids['custom_field_id']; + + // 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_' . $custom_field_id] = "12345"; + + $this->callAPISuccess($this->_entity, 'create', $params, __FUNCTION__, __FILE__); + + // Retrieve the activity, and chain loc block using $value. + $result = $this->callAPIAndDocument($this->_entity, 'get', array( + 'custom_' . $custom_field_id => "12345", + 'api.LocBlock.get' => array("id" => '$value.loc_block_id'), + ), __FUNCTION__, __FILE__); + + $this->assertEquals(1, $result['count']); + + $this->customFieldDelete($ids['custom_field_id']); + $this->customGroupDelete($ids['custom_group_id']); + $this->callAPISuccess('event', 'delete', array( + 'id' => $result['id'], + 'skip_undelete' => TRUE, + )); + } + + /** * Test that an event with a price set can be created. */