From 22e9710187d08126b6a86005c79662d29accba30 Mon Sep 17 00:00:00 2001 From: Johan Vervloet Date: Tue, 10 Mar 2015 15:39:15 +0100 Subject: [PATCH] A unit test for searching memberships on custom field values. --- tests/phpunit/api/v3/MembershipTest.php | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index aa5d0937a2..e31e2dc753 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -714,6 +714,40 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $this->assertEquals("custom string", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); } + /** + * Search on custom field value. + */ + public function testSearchWithCustomDataCRM16036() { + // Create a custom field on membership + $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); + + // Create a new membership, but don't assign anything to the custom field. + $params = $this->_params; + $result = $this->callAPIAndDocument( + $this->_entity, + 'create', + $params, + __FUNCTION__, + __FILE__, + NULL, + 'SearchWithCustomData'); + + // search memberships with CRM-16036 as custom field value. + // Since we did not touch the custom field of any membership, + // this should not return any results. + $check = $this->callAPISuccess($this->_entity, 'get', array( + 'custom_' . $ids['custom_field_id'] => "CRM-16036", + )); + + // Cleanup. + $this->callAPISuccess($this->_entity, 'delete', array( + 'id' => $result['id'], + )); + + // Assert. + $this->assertEquals(0, $check['count']); + } + /** * Test civicrm_contact_memberships_create with membership id (edit * membership). -- 2.25.1